Skip to content

Commit 7cc255a

Browse files
committed
Fix data on clipboard invalid exception
1 parent a8432b2 commit 7cc255a

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/Flow.Launcher.Plugin.ClipboardPlus.Core/Data/Models/Clipboard/BaseClipboardHandle.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ internal class BaseClipboardHandle
1717
#region Fields
1818

1919
protected static readonly HRESULT CLIPBOARD_E_CANT_OPEN = unchecked((HRESULT)0x800401D0);
20+
protected static readonly HRESULT CLIPBOARD_E_BAD_DATA = unchecked((HRESULT)0x800401D3);
2021
protected static readonly HRESULT RPC_SERVER_UNAVAILABLE = unchecked((HRESULT)0x800706BA);
2122
protected static readonly HRESULT DV_E_FORMATETC = unchecked((HRESULT)0x80040064);
2223
protected static readonly HRESULT DV_E_CLIPFORMAT = unchecked((HRESULT)0x8004006A);

src/Flow.Launcher.Plugin.ClipboardPlus.Core/Data/Models/Clipboard/ClipboardHandleW.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,12 @@ await Win32Helper.StartSTATaskAsync(() =>
357357
// System.Runtime.InteropServices.COMException (0x800401D0)
358358
// OpenClipboard Failed (0x800401D0 (CLIPBRD_E_CANT_OPEN))
359359
}
360+
catch (COMException e) when (e.HResult == CLIPBOARD_E_BAD_DATA)
361+
{
362+
// Sometimes data on clipboard is invalid.
363+
// System.Runtime.InteropServices.COMException (0x800401D3)
364+
// Bad data in clipboard (0x800401D3 (CLIPBRD_E_BAD_DATA))
365+
}
360366
catch (COMException e) when (e.HResult == RPC_SERVER_UNAVAILABLE)
361367
{
362368
// Sometimes the clipboard is locked and cannot be accessed.

src/Flow.Launcher.Plugin.ClipboardPlus.Core/Data/Models/Clipboard/ClipboardHandleWin.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ private async void OnClipboardChanged(object? sender, object _)
232232
// System.Runtime.InteropServices.COMException (0x800401D0)
233233
// OpenClipboard Failed (0x800401D0 (CLIPBRD_E_CANT_OPEN))
234234
}
235+
catch (COMException e) when (e.HResult == CLIPBOARD_E_BAD_DATA)
236+
{
237+
// Sometimes data on clipboard is invalid.
238+
// System.Runtime.InteropServices.COMException (0x800401D3)
239+
// Bad data in clipboard (0x800401D3 (CLIPBRD_E_BAD_DATA))
240+
}
235241
catch (COMException e) when (e.HResult == RPC_SERVER_UNAVAILABLE)
236242
{
237243
// Sometimes the clipboard is locked and cannot be accessed.

0 commit comments

Comments
 (0)