Fix clipboard crash: use SetDataObject(false) to skip Flush()

This commit is contained in:
SuperDooper
2026-05-11 21:44:21 +02:00
parent 5a799899ef
commit 24dbf013e7
+9 -1
View File
@@ -495,13 +495,21 @@ public partial class PopupWindow : Window
private void CopyDiag_Click(object s, RoutedEventArgs e) private void CopyDiag_Click(object s, RoutedEventArgs e)
{ {
try
{
// SetDataObject(data, false) skips Flush() — avoids CLIPBRD_E_CANT_OPEN crash
var diagText = BuildDiagText(); var diagText = BuildDiagText();
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
try { Clipboard.SetText(diagText); break; } try { Clipboard.SetDataObject(diagText, false); break; }
catch (Exception) { System.Threading.Thread.Sleep(100); } catch (Exception) { System.Threading.Thread.Sleep(100); }
} }
CopyDiagButton.Content = "Copied! (IDs redacted)"; CopyDiagButton.Content = "Copied! (IDs redacted)";
}
catch (Exception)
{
CopyDiagButton.Content = "Copy failed";
}
var t = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1.5) }; var t = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1.5) };
t.Tick += (_, _) => { CopyDiagButton.Content = "Copy All"; t.Stop(); }; t.Tick += (_, _) => { CopyDiagButton.Content = "Copy All"; t.Stop(); };
t.Start(); t.Start();