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 8d09191d2d.

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 <orgads@gmail.com>
This commit is contained in:
Andre Hartmann
2020-12-28 16:55:19 +01:00
committed by André Hartmann
parent 6ebfc77d35
commit c12a3909bb

View File

@@ -32,7 +32,7 @@
namespace Core { namespace Core {
namespace Internal { namespace Internal {
enum class EngineAction { Reset, Abort }; enum class EngineAction { Reset = 1, Abort };
JavaScriptFilter::JavaScriptFilter() JavaScriptFilter::JavaScriptFilter()
{ {
@@ -98,11 +98,13 @@ void JavaScriptFilter::accept(Core::LocatorFilterEntry selection, QString *newTe
if (selection.internalData.isNull()) if (selection.internalData.isNull())
return; return;
if (selection.internalData.canConvert<EngineAction>() const EngineAction action = selection.internalData.value<EngineAction>();
&& selection.internalData.value<EngineAction>() == EngineAction::Reset) { if (action == EngineAction::Reset) {
m_engine.reset(); m_engine.reset();
return; return;
} }
if (action == EngineAction::Abort)
return;
QClipboard *clipboard = QGuiApplication::clipboard(); QClipboard *clipboard = QGuiApplication::clipboard();
clipboard->setText(selection.internalData.toString()); clipboard->setText(selection.internalData.toString());