From b7bfcc3786029f3f69ae4fe1caf164aabe35ca5f Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Thu, 20 Feb 2020 12:16:32 +0100 Subject: [PATCH] CppTools: Do not reindex all sources on project update When CMake was run it would cause an update, which would have a cancelAndWaitForFinished on the future interface. The CppTools would have the future interface added on all updates, and even though an indexing job would be finished, it would be picked up as active and cancelled, which would be interpreted as action from the user to cancel the indexing and cause a full reindex. This patch makes sure that if an indexing job has finished, it doesn't register as active, and only the jobs that actually do some work, and will be finished will wait for the cancel signal. Change-Id: If8a4db2a4a7a5707a360db84affe794ab0678d38 Reviewed-by: Tobias Hunger --- src/plugins/cpptools/cppmodelmanager.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index e836fba5905..a4523a6065f 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -971,8 +971,6 @@ void CppModelManager::recalculateProjectPartMappings() void CppModelManager::watchForCanceledProjectIndexer(const QVector> &futures, ProjectExplorer::Project *project) { - d->m_projectToIndexerCanceled.insert(project, false); - for (const QFuture &future : futures) { if (future.isCanceled() || future.isFinished()) continue; @@ -983,7 +981,8 @@ void CppModelManager::watchForCanceledProjectIndexer(const QVector d->m_projectToIndexerCanceled.insert(project, true); watcher->deleteLater(); }); - connect(watcher, &QFutureWatcher::finished, this, [watcher]() { + connect(watcher, &QFutureWatcher::finished, this, [this, project, watcher]() { + d->m_projectToIndexerCanceled.remove(project); watcher->deleteLater(); }); watcher->setFuture(future); @@ -1114,6 +1113,9 @@ QFuture CppModelManager::updateProjectInfo(QFutureInterface &futureI // Trigger reindexing const QFuture indexingFuture = updateSourceFiles(futureInterface, filesToReindex, ForcedProgressNotification); + if (!filesToReindex.isEmpty()) { + d->m_projectToIndexerCanceled.insert(project, false); + } watchForCanceledProjectIndexer({futureInterface.future(), indexingFuture}, project); return indexingFuture; }