diff --git a/src/plugins/coreplugin/locator/commandlocator.cpp b/src/plugins/coreplugin/locator/commandlocator.cpp index 387cae9fef6..9c644f4f998 100644 --- a/src/plugins/coreplugin/locator/commandlocator.cpp +++ b/src/plugins/coreplugin/locator/commandlocator.cpp @@ -17,7 +17,7 @@ namespace Core { struct CommandLocatorPrivate { QList commands; - QList> commandsData; + QList> commandsData; }; /*! @@ -61,7 +61,7 @@ void CommandLocator::prepareSearch(const QString &entry) continue; QAction *action = command->action(); if (action && action->isEnabled()) - d->commandsData.append({i, action->text()}); + d->commandsData.append({action, action->text()}); } } @@ -77,8 +77,17 @@ QList CommandLocator::matchesFor(QFutureInterface= 0) { - LocatorFilterEntry filterEntry(this, text); - filterEntry.internalData = QVariant(pair.first); + QAction *action = pair.first; + LocatorFilterEntry filterEntry; + filterEntry.displayName = text; + filterEntry.acceptor = [action] { + // avoid nested stack trace and blocking locator by delayed triggering + QMetaObject::invokeMethod(action, [action] { + if (action->isEnabled()) + action->trigger(); + }, Qt::QueuedConnection); + return AcceptResult(); + }; filterEntry.highlightInfo = {index, int(entry.length())}; if (index == 0) @@ -91,21 +100,4 @@ QList CommandLocator::matchesFor(QFutureInterface= 0 && index < d->commands.size(), return); - QAction *action = d->commands.at(index)->action(); - // avoid nested stack trace and blocking locator by delayed triggering - QMetaObject::invokeMethod(action, [action] { - if (action->isEnabled()) - action->trigger(); - }, Qt::QueuedConnection); -} - } // namespace Core diff --git a/src/plugins/coreplugin/locator/commandlocator.h b/src/plugins/coreplugin/locator/commandlocator.h index 8199661bed6..e47fbde5c41 100644 --- a/src/plugins/coreplugin/locator/commandlocator.h +++ b/src/plugins/coreplugin/locator/commandlocator.h @@ -26,9 +26,6 @@ public: void prepareSearch(const QString &entry) override; QList matchesFor(QFutureInterface &future, const QString &entry) override; - void accept(const LocatorFilterEntry &selection, - QString *newText, int *selectionStart, int *selectionLength) const override; - private: CommandLocatorPrivate *d = nullptr; };