aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2018-04-27 16:05:22 +0200
committerRobert Loehning <robert.loehning@qt.io>2018-05-02 16:47:26 +0000
commiteecbfc214eeb3c0e5433123ca62d5359023ba696 (patch)
treef41e01d39eaa2660904272572ea48f68396f4f59
parente8b13fe3c9e0984817d6b7417b43964c0433fcdd (diff)
VCS locator filters: Let locator close its popup
By delaying the execution of the action with a singleShot. Both CommandLocator filters and the menu bar filter are affected. Task-number: QTCREATORBUG-18863 Change-Id: I4f3d39410621c2d578bc9f7af7357af372a15b73 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Robert Loehning <robert.loehning@qt.io> Reviewed-by: André Hartmann <aha_1980@gmx.de>
-rw-r--r--src/plugins/coreplugin/locator/commandlocator.cpp8
-rw-r--r--src/plugins/coreplugin/menubarfilter.cpp9
2 files changed, 13 insertions, 4 deletions
diff --git a/src/plugins/coreplugin/locator/commandlocator.cpp b/src/plugins/coreplugin/locator/commandlocator.cpp
index 2768dca3a3..7546d0f9b0 100644
--- a/src/plugins/coreplugin/locator/commandlocator.cpp
+++ b/src/plugins/coreplugin/locator/commandlocator.cpp
@@ -31,6 +31,7 @@
#include <utils/stringutils.h>
#include <QAction>
+#include <QTimer>
namespace Core {
@@ -104,8 +105,11 @@ void CommandLocator::accept(LocatorFilterEntry entry,
const int index = entry.internalData.toInt();
QTC_ASSERT(index >= 0 && index < d->commands.size(), return);
QAction *action = d->commands.at(index)->action();
- QTC_ASSERT(action->isEnabled(), return);
- action->trigger();
+ // avoid nested stack trace and blocking locator by delayed triggering
+ QTimer::singleShot(0, action, [action] {
+ if (action->isEnabled())
+ action->trigger();
+ });
}
void CommandLocator::refresh(QFutureInterface<void> &)
diff --git a/src/plugins/coreplugin/menubarfilter.cpp b/src/plugins/coreplugin/menubarfilter.cpp
index 5c3c4414db..3847a5b382 100644
--- a/src/plugins/coreplugin/menubarfilter.cpp
+++ b/src/plugins/coreplugin/menubarfilter.cpp
@@ -37,6 +37,7 @@
#include <QMenuBar>
#include <QPointer>
#include <QRegularExpression>
+#include <QTimer>
using namespace Core::Internal;
using namespace Core;
@@ -78,8 +79,12 @@ void MenuBarFilter::accept(LocatorFilterEntry selection, QString *newText,
Q_UNUSED(newText);
Q_UNUSED(selectionStart);
Q_UNUSED(selectionLength);
- if (auto action = selection.internalData.value<QPointer<QAction>>())
- action->trigger();
+ if (auto action = selection.internalData.value<QPointer<QAction>>()) {
+ QTimer::singleShot(0, action, [action] {
+ if (action->isEnabled())
+ action->trigger();
+ });
+ }
}
void MenuBarFilter::refresh(QFutureInterface<void> &future)