summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppmodelmanager.cpp
diff options
context:
space:
mode:
authorCristian Adam <cristian.adam@qt.io>2020-02-20 12:16:32 +0100
committerCristian Adam <cristian.adam@qt.io>2020-02-20 13:53:36 +0000
commitb7bfcc3786029f3f69ae4fe1caf164aabe35ca5f (patch)
tree4ada6637dad4995472369cdbe8bf790ae2559797 /src/plugins/cpptools/cppmodelmanager.cpp
parent552ccd6a616b7f74f7948457b861a1124e2bf6cc (diff)
downloadqt-creator-b7bfcc3786029f3f69ae4fe1caf164aabe35ca5f.tar.gz
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 <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/cpptools/cppmodelmanager.cpp')
-rw-r--r--src/plugins/cpptools/cppmodelmanager.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp
index e836fba590..a4523a6065 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<QFuture<void>> &futures,
ProjectExplorer::Project *project)
{
- d->m_projectToIndexerCanceled.insert(project, false);
-
for (const QFuture<void> &future : futures) {
if (future.isCanceled() || future.isFinished())
continue;
@@ -983,7 +981,8 @@ void CppModelManager::watchForCanceledProjectIndexer(const QVector<QFuture<void>
d->m_projectToIndexerCanceled.insert(project, true);
watcher->deleteLater();
});
- connect(watcher, &QFutureWatcher<void>::finished, this, [watcher]() {
+ connect(watcher, &QFutureWatcher<void>::finished, this, [this, project, watcher]() {
+ d->m_projectToIndexerCanceled.remove(project);
watcher->deleteLater();
});
watcher->setFuture(future);
@@ -1114,6 +1113,9 @@ QFuture<void> CppModelManager::updateProjectInfo(QFutureInterface<void> &futureI
// Trigger reindexing
const QFuture<void> indexingFuture = updateSourceFiles(futureInterface, filesToReindex,
ForcedProgressNotification);
+ if (!filesToReindex.isEmpty()) {
+ d->m_projectToIndexerCanceled.insert(project, false);
+ }
watchForCanceledProjectIndexer({futureInterface.future(), indexingFuture}, project);
return indexingFuture;
}