Commit 521423b4 authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppTools: Call ProjectInfo::finish when we get it

No need to require the project managers to do this. Also, it is easy to
forget.

Change-Id: I96f7a5e5547418678af9653e5753c372f0880e5a
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
parent d006fc41
......@@ -305,6 +305,5 @@ void AutotoolsProject::updateCppCodeModel()
foreach (Core::Id language, languages)
setProjectLanguage(language, true);
pInfo.finish();
m_codeModelFuture = modelManager->updateProjectInfo(pInfo);
}
......@@ -623,7 +623,6 @@ CppTools::ProjectInfo createProjectInfo(ProjectExplorer::Project *project,
const CppTools::ProjectPart::Ptr projectPart = createProjectPart(files, defines);
ProjectInfo projectInfo = ProjectInfo(project);
projectInfo.appendProjectPart(projectPart);
projectInfo.finish();
return projectInfo;
}
......
......@@ -135,7 +135,6 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
setProjectLanguage(lid, true);
m_codeModelFuture.cancel();
pinfo.finish();
m_codeModelFuture = modelmanager->updateProjectInfo(pinfo);
updateQmlJSCodeModel();
......
......@@ -823,21 +823,24 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &newProjectIn
if (!newProjectInfo.isValid())
return QFuture<void>();
ProjectInfo theNewProjectInfo = newProjectInfo;
theNewProjectInfo.finish();
QSet<QString> filesToReindex;
QStringList removedProjectParts;
bool filesRemoved = false;
ProjectExplorer::Project *project = newProjectInfo.project().data();
ProjectExplorer::Project *project = theNewProjectInfo.project().data();
{ // Only hold the mutex for a limited scope, so the dumping afterwards does not deadlock.
QMutexLocker projectLocker(&d->m_projectMutex);
const QSet<QString> newSourceFiles = newProjectInfo.sourceFiles();
const QSet<QString> newSourceFiles = theNewProjectInfo.sourceFiles();
// Check if we can avoid a full reindexing
ProjectInfo oldProjectInfo = d->m_projectToProjectsInfo.value(project);
const bool previousIndexerCanceled = d->m_projectToIndexerCanceled.value(project, false);
if (!previousIndexerCanceled && oldProjectInfo.isValid()) {
ProjectInfoComparer comparer(oldProjectInfo, newProjectInfo);
ProjectInfoComparer comparer(oldProjectInfo, theNewProjectInfo);
if (comparer.configurationOrFilesChanged()) {
d->m_dirty = true;
......@@ -880,7 +883,7 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &newProjectIn
}
// Update Project/ProjectInfo and File/ProjectPart table
d->m_projectToProjectsInfo.insert(project, newProjectInfo);
d->m_projectToProjectsInfo.insert(project, theNewProjectInfo);
recalculateProjectPartMappings();
} // Mutex scope
......@@ -898,7 +901,7 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &newProjectIn
emit projectPartsRemoved(removedProjectParts);
// Announce added project parts
emit projectPartsUpdated(newProjectInfo.project().data());
emit projectPartsUpdated(theNewProjectInfo.project().data());
// Ideally, we would update all the editor documents that depend on the 'filesToReindex'.
// However, on e.g. a session restore first the editor documents are created and then the
......
......@@ -115,7 +115,6 @@ public:
part->files.append(projectFile);
}
projectInfo.appendProjectPart(part);
projectInfo.finish();
}
ModelManagerTestHelper *modelManagerTestHelper;
......@@ -194,7 +193,6 @@ void CppToolsPlugin::test_modelmanager_paths_are_clean()
part->headerPaths = { HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath),
HeaderPath(testDataDir.frameworksDir(false), HeaderPath::FrameworkPath) };
pi.appendProjectPart(part);
pi.finish();
mm->updateProjectInfo(pi);
......@@ -231,7 +229,6 @@ void CppToolsPlugin::test_modelmanager_framework_headers()
_("test_modelmanager_framework_headers.cpp"));
part->files << ProjectFile(source, ProjectFile::CXXSource);
pi.appendProjectPart(part);
pi.finish();
mm->updateProjectInfo(pi).waitForFinished();
QCoreApplication::processEvents();
......@@ -279,7 +276,6 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files()
part->headerPaths = { HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath) };
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
pi.appendProjectPart(part);
pi.finish();
QSet<QString> refreshedFiles = helper.updateProjectInfo(pi);
QCOMPARE(refreshedFiles.size(), 1);
......@@ -297,7 +293,6 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files()
part->projectDefines = QByteArray("#define TEST_DEFINE 1\n");
pi = ProjectInfo(project);
pi.appendProjectPart(part);
pi.finish();
refreshedFiles = helper.updateProjectInfo(pi);
......@@ -338,7 +333,6 @@ void CppToolsPlugin::test_modelmanager_refresh_several_times()
part->files.append(ProjectFile(testHeader2, ProjectFile::CXXHeader));
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
pi.appendProjectPart(part);
pi.finish();
mm->updateProjectInfo(pi);
CPlusPlus::Snapshot snapshot;
......@@ -358,7 +352,6 @@ void CppToolsPlugin::test_modelmanager_refresh_several_times()
part->files.append(ProjectFile(testHeader2, ProjectFile::CXXHeader));
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
pi.appendProjectPart(part);
pi.finish();
refreshedFiles = helper.updateProjectInfo(pi);
QCOMPARE(refreshedFiles.size(), 3);
......@@ -402,7 +395,6 @@ void CppToolsPlugin::test_modelmanager_refresh_test_for_changes()
part->qtVersion = ProjectPart::Qt5;
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
pi.appendProjectPart(part);
pi.finish();
// Reindexing triggers a reparsing thread
helper.resetRefreshedSourceFiles();
......@@ -440,7 +432,6 @@ void CppToolsPlugin::test_modelmanager_refresh_added_and_purge_removed()
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
part->files.append(ProjectFile(testHeader1, ProjectFile::CXXHeader));
pi.appendProjectPart(part);
pi.finish();
CPlusPlus::Snapshot snapshot;
QSet<QString> refreshedFiles;
......@@ -463,7 +454,6 @@ void CppToolsPlugin::test_modelmanager_refresh_added_and_purge_removed()
newPart->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
newPart->files.append(ProjectFile(testHeader2, ProjectFile::CXXHeader));
pi.appendProjectPart(newPart);
pi.finish();
refreshedFiles = helper.updateProjectInfo(pi);
......@@ -505,7 +495,6 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_
part->files.append(ProjectFile(file, ProjectFile::CXXSource));
pi = ProjectInfo(project);
pi.appendProjectPart(part);
pi.finish();
Document::Ptr document;
CPlusPlus::Snapshot snapshot;
......@@ -539,7 +528,6 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_
part->files.append(ProjectFile(file, ProjectFile::CXXSource));
pi = ProjectInfo(project);
pi.appendProjectPart(part);
pi.finish();
refreshedFiles = helper.updateProjectInfo(pi);
......@@ -804,7 +792,6 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
ProjectInfo pi = ProjectInfo(project);
pi.appendProjectPart(part1);
pi.appendProjectPart(part2);
pi.finish();
helper.updateProjectInfo(pi);
QCOMPARE(mm->snapshot().size(), 4);
......@@ -873,7 +860,6 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
ProjectInfo pi = ProjectInfo(project);
pi.appendProjectPart(part1);
pi.appendProjectPart(part2);
pi.finish();
helper.updateProjectInfo(pi);
QCOMPARE(mm->snapshot().size(), 4);
......@@ -955,7 +941,6 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
ProjectInfo pi = ProjectInfo(project);
pi.appendProjectPart(part1);
pi.appendProjectPart(part2);
pi.finish();
helper.updateProjectInfo(pi);
......@@ -1035,7 +1020,6 @@ void CppToolsPlugin::test_modelmanager_updateEditorsAfterProjectUpdate()
ProjectInfo pi = ProjectInfo(project);
pi.appendProjectPart(part);
pi.finish();
helper.updateProjectInfo(pi);
// ... and check for updated editor document A
......
......@@ -371,7 +371,6 @@ void GenericProject::refreshCppCodeModel()
foreach (Id language, languages)
setProjectLanguage(language, true);
pInfo.finish();
m_codeModelFuture = modelManager->updateProjectInfo(pInfo);
}
......
......@@ -1030,8 +1030,6 @@ void QbsProject::updateCppCodeModel()
}
}
pinfo.finish();
CppTools::GeneratedCodeModelSupport::update(m_extraCompilers);
// Update the code model
......
......@@ -473,8 +473,6 @@ void QmakeProject::updateCppCodeModel()
}
}
projectInfo.finish();
CppTools::GeneratedCodeModelSupport::update(generators);
m_codeModelFuture = CppTools::CppModelManager::instance()->updateProjectInfo(projectInfo);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment