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>
This commit is contained in:
Cristian Adam
2020-02-20 12:16:32 +01:00
parent 552ccd6a61
commit b7bfcc3786

View File

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