From eb2f49c39826cb32a00d17c9d37824d54001a3d8 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Fri, 9 Aug 2019 14:40:06 +0200 Subject: [PATCH] CMake: Fix race/crash on project open When the filesystem scan takes longer than the cmake parsing, then resetData() was called on BuildDirManager by the CMakeBuildConfiguration before the CMakeProject had requested its data. Move some code back into CMakeProject to resolve this issue. Change-Id: Ib21bdd63fdca79c2ad39a7e060df438b456700b4 Reviewed-by: Eike Ziller --- .../cmakeprojectmanager/cmakebuildconfiguration.cpp | 8 -------- src/plugins/cmakeprojectmanager/cmakeproject.cpp | 4 ++++ src/plugins/cmakeprojectmanager/projecttreehelper.cpp | 2 ++ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp index a9fc94c4f93..6c1f835bdad 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp @@ -539,14 +539,6 @@ void CMakeBuildConfiguration::handleParsingSucceeded() } project()->handleParsingSuccess(this); - - { - m_buildDirManager.resetData(); - } - - { - emitBuildTypeChanged(); - } } std::unique_ptr CMakeBuildConfiguration::generateProjectTree( diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index bbfcd41f668..4fb6bd297a6 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -269,6 +269,10 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc) emit fileListChanged(); + emit bc->emitBuildTypeChanged(); + + bc->m_buildDirManager.resetData(); // Clear remaining data + qCDebug(cmakeProjectLog) << "All CMake project data up to date."; } diff --git a/src/plugins/cmakeprojectmanager/projecttreehelper.cpp b/src/plugins/cmakeprojectmanager/projecttreehelper.cpp index 668b2ce5d5e..46d0810b608 100644 --- a/src/plugins/cmakeprojectmanager/projecttreehelper.cpp +++ b/src/plugins/cmakeprojectmanager/projecttreehelper.cpp @@ -177,6 +177,8 @@ void addHeaderNodes(ProjectNode *root, QSet &seenHeaders, const QList &allFiles) { + QTC_ASSERT(root, return ); + if (root->isEmpty()) return;