From 216887b7d76c75cb7d9cebeabdee93cb8b1bc6aa Mon Sep 17 00:00:00 2001 From: Haven1433 Date: Fri, 19 Aug 2022 21:53:38 -0500 Subject: [PATCH] retry clipboard on failure --- .../Implementations/WindowsFileSystem.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/HexManiac.WPF/Implementations/WindowsFileSystem.cs b/src/HexManiac.WPF/Implementations/WindowsFileSystem.cs index ca93e54e..1c1be94c 100644 --- a/src/HexManiac.WPF/Implementations/WindowsFileSystem.cs +++ b/src/HexManiac.WPF/Implementations/WindowsFileSystem.cs @@ -45,9 +45,14 @@ namespace HavenSoft.HexManiac.WPF.Implementations { try { Clipboard.SetDataObject(value, true); } catch (COMException) { - // something went wrong... we couldn't copy - var window = (MainWindow)Application.Current.MainWindow; - window.ViewModel.ErrorMessage = "Could not copy"; + try { + // try again, but don't try to persist the value after app exit + Clipboard.SetDataObject(value); + } catch (COMException) { + // something went wrong... we couldn't copy + var window = (MainWindow)Application.Current.MainWindow; + window.ViewModel.ErrorMessage = "Could not copy"; + } } } }