forked from qt-creator/qt-creator
Locator: Reuse TaskTreeRunner for filters refreshing
Change-Id: I9db6c24491ce5f972707160bf84da01fce67657b Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
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<ILocatorFilter *> &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<GroupItem> tasks{parallel};
|
||||
for (ILocatorFilter *filter : std::as_const(m_refreshingFilters)) {
|
||||
const auto task = filter->refreshRecipe();
|
||||
@@ -394,16 +403,7 @@ void Locator::refresh(const QList<ILocatorFilter *> &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)
|
||||
|
@@ -8,11 +8,11 @@
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
#include <solutions/tasking/tasktreerunner.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
|
||||
namespace Tasking { class TaskTree; }
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
@@ -71,7 +71,7 @@ private:
|
||||
QList<ILocatorFilter *> m_customFilters;
|
||||
QMap<Utils::Id, QAction *> m_filterActionMap;
|
||||
QTimer m_refreshTimer;
|
||||
std::unique_ptr<Tasking::TaskTree> m_taskTree;
|
||||
Tasking::TaskTreeRunner m_taskTreeRunner;
|
||||
QList<ILocatorFilter *> m_refreshingFilters;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user