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; }