From c12a3909bb696e52d45e384ef21397710380fb1f Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Mon, 28 Dec 2020 16:55:19 +0100 Subject: [PATCH] JavaScriptFilter: Fix copying to clipboard It seems that QStrings stored in a QVariant can always be converted to EngineAction, therefore this check can be removed. The conversion then always resulted in the value zero, which got equal to EngineAction::Reset in commit 8d09191d2d1d. While at it, forbid copying an empty string to the clipboard, when the engine was aborted due to a timeout. Change-Id: Iaa4d9af52d4afd0e82f3b542d5f4e79bc8f6bdca Reviewed-by: Orgad Shaneh --- src/plugins/coreplugin/locator/javascriptfilter.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/coreplugin/locator/javascriptfilter.cpp b/src/plugins/coreplugin/locator/javascriptfilter.cpp index 245ddb61e20..8600580e0cd 100644 --- a/src/plugins/coreplugin/locator/javascriptfilter.cpp +++ b/src/plugins/coreplugin/locator/javascriptfilter.cpp @@ -32,7 +32,7 @@ namespace Core { namespace Internal { -enum class EngineAction { Reset, Abort }; +enum class EngineAction { Reset = 1, Abort }; JavaScriptFilter::JavaScriptFilter() { @@ -98,11 +98,13 @@ void JavaScriptFilter::accept(Core::LocatorFilterEntry selection, QString *newTe if (selection.internalData.isNull()) return; - if (selection.internalData.canConvert() - && selection.internalData.value() == EngineAction::Reset) { + const EngineAction action = selection.internalData.value(); + if (action == EngineAction::Reset) { m_engine.reset(); return; } + if (action == EngineAction::Abort) + return; QClipboard *clipboard = QGuiApplication::clipboard(); clipboard->setText(selection.internalData.toString());