From eecbfc214eeb3c0e5433123ca62d5359023ba696 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 27 Apr 2018 16:05:22 +0200 Subject: [PATCH] VCS locator filters: Let locator close its popup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Robert Loehning Reviewed-by: André Hartmann --- src/plugins/coreplugin/locator/commandlocator.cpp | 8 ++++++-- src/plugins/coreplugin/menubarfilter.cpp | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/plugins/coreplugin/locator/commandlocator.cpp b/src/plugins/coreplugin/locator/commandlocator.cpp index 2768dca3a3b..7546d0f9b06 100644 --- a/src/plugins/coreplugin/locator/commandlocator.cpp +++ b/src/plugins/coreplugin/locator/commandlocator.cpp @@ -31,6 +31,7 @@ #include #include +#include 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 &) diff --git a/src/plugins/coreplugin/menubarfilter.cpp b/src/plugins/coreplugin/menubarfilter.cpp index 5c3c4414db8..3847a5b3828 100644 --- a/src/plugins/coreplugin/menubarfilter.cpp +++ b/src/plugins/coreplugin/menubarfilter.cpp @@ -37,6 +37,7 @@ #include #include #include +#include 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>()) - action->trigger(); + if (auto action = selection.internalData.value>()) { + QTimer::singleShot(0, action, [action] { + if (action->isEnabled()) + action->trigger(); + }); + } } void MenuBarFilter::refresh(QFutureInterface &future)