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>
This commit is contained in:
Eike Ziller
2018-04-27 16:05:22 +02:00
committed by Robert Loehning
parent e8b13fe3c9
commit eecbfc214e
2 changed files with 13 additions and 4 deletions

View File

@@ -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);
// 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> &)

View File

@@ -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>>())
if (auto action = selection.internalData.value<QPointer<QAction>>()) {
QTimer::singleShot(0, action, [action] {
if (action->isEnabled())
action->trigger();
});
}
}
void MenuBarFilter::refresh(QFutureInterface<void> &future)