Merge pull request #3816 from Flow-Launcher/clipboard_invalid

Use try-catch for query text box paste
This commit is contained in:
Jack Ye 2025-07-12 07:57:27 +08:00 committed by GitHub
commit b60cca42ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -44,6 +44,9 @@ namespace Flow.Launcher
#region Private Fields #region Private Fields
// Class Name
private static readonly string ClassName = nameof(MainWindow);
// Dependency Injection // Dependency Injection
private readonly Settings _settings; private readonly Settings _settings;
private readonly Theme _theme; private readonly Theme _theme;
@ -1255,6 +1258,8 @@ namespace Flow.Launcher
} }
private void QueryTextBox_OnPaste(object sender, DataObjectPastingEventArgs e) private void QueryTextBox_OnPaste(object sender, DataObjectPastingEventArgs e)
{
try
{ {
var isText = e.SourceDataObject.GetDataPresent(DataFormats.UnicodeText, true); var isText = e.SourceDataObject.GetDataPresent(DataFormats.UnicodeText, true);
if (isText) if (isText)
@ -1266,6 +1271,11 @@ namespace Flow.Launcher
e.DataObject = data; e.DataObject = data;
} }
} }
catch (Exception ex)
{
App.API.LogException(ClassName, "Failed to paste text", ex);
}
}
private void QueryTextBox_KeyUp(object sender, KeyEventArgs e) private void QueryTextBox_KeyUp(object sender, KeyEventArgs e)
{ {