diff --git a/src/plugins/coreplugin/locator/locator.cpp b/src/plugins/coreplugin/locator/locator.cpp index 9dcd9b34fc2..0666831355a 100644 --- a/src/plugins/coreplugin/locator/locator.cpp +++ b/src/plugins/coreplugin/locator/locator.cpp @@ -35,6 +35,7 @@ #include +using namespace Tasking; using namespace Utils; namespace Core { @@ -150,7 +151,7 @@ bool Locator::delayedInitialize() void Locator::aboutToShutdown() { m_refreshTimer.stop(); - m_taskTree.reset(); + m_taskTreeRunner.reset(); } void Locator::loadSettings() @@ -377,10 +378,18 @@ void Locator::refresh(const QList &filters) if (ExtensionSystem::PluginManager::isShuttingDown()) return; - m_taskTree.reset(); // Superfluous, just for clarity. The next reset() below is enough. + m_taskTreeRunner.reset(); // Superfluous, just for clarity. The start() below is enough. m_refreshingFilters = Utils::filteredUnique(m_refreshingFilters + filters); - using namespace Tasking; + const auto onTreeSetup = [](TaskTree *taskTree) { + auto progress = new TaskProgress(taskTree); + progress->setDisplayName(Tr::tr("Updating Locator Caches")); + }; + const auto onTreeDone = [this](DoneWith result) { + if (result == DoneWith::Success) + saveSettings(); + }; + QList tasks{parallel}; for (ILocatorFilter *filter : std::as_const(m_refreshingFilters)) { const auto task = filter->refreshRecipe(); @@ -394,16 +403,7 @@ void Locator::refresh(const QList &filters) }; tasks.append(group); } - - m_taskTree.reset(new TaskTree{tasks}); - connect(m_taskTree.get(), &TaskTree::done, this, [this](DoneWith result) { - if (result == DoneWith::Success) - saveSettings(); - m_taskTree.release()->deleteLater(); - }); - auto progress = new TaskProgress(m_taskTree.get()); - progress->setDisplayName(Tr::tr("Updating Locator Caches")); - m_taskTree->start(); + m_taskTreeRunner.start(tasks, onTreeSetup, onTreeDone); } void Locator::showFilter(ILocatorFilter *filter, LocatorWidget *widget) diff --git a/src/plugins/coreplugin/locator/locator.h b/src/plugins/coreplugin/locator/locator.h index e2069e99e99..cee26782a6f 100644 --- a/src/plugins/coreplugin/locator/locator.h +++ b/src/plugins/coreplugin/locator/locator.h @@ -8,11 +8,11 @@ #include +#include + #include #include -namespace Tasking { class TaskTree; } - namespace Core { namespace Internal { @@ -71,7 +71,7 @@ private: QList m_customFilters; QMap m_filterActionMap; QTimer m_refreshTimer; - std::unique_ptr m_taskTree; + Tasking::TaskTreeRunner m_taskTreeRunner; QList m_refreshingFilters; };