From 488bd7eddbe83f00b4f61be4ddbaadd08bb52d16 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 27 Feb 2020 14:46:16 +0100 Subject: [PATCH] CMake: Check parseGuard.guardsProject() ... before overwriting the current guard, retaining the state of the current guard in the error case. Change-Id: I45ec43d48a9a13b9b59a5bbe6415a457b974b654 Reviewed-by: Tobias Hunger Reviewed-by: Alessandro Portale --- .../cmakeprojectmanager/cmakebuildsystem.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index 493939dd89a..fa8396e92d8 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -204,7 +204,7 @@ CMakeBuildSystem::CMakeBuildSystem(CMakeBuildConfiguration *bc) }); connect(project(), &Project::projectFileIsDirty, this, [this]() { - if (m_buildConfiguration->isActive()) { + if (m_buildConfiguration->isActive() && !isParsing()) { const auto cmake = CMakeKitAspect::cmakeTool(m_buildConfiguration->target()->kit()); if (cmake && cmake->isAutoRun()) { qCDebug(cmakeBuildSystemLog) << "Requesting parse due to dirty project file"; @@ -235,9 +235,20 @@ CMakeBuildSystem::~CMakeBuildSystem() void CMakeBuildSystem::triggerParsing() { qCDebug(cmakeBuildSystemLog) << "Parsing has been triggered"; - m_currentGuard = guardParsingRun(); - QTC_ASSERT(m_currentGuard.guardsProject(), return ); + auto guard = guardParsingRun(); + + if (!guard.guardsProject()) { + // This can legitimately trigger if e.g. Build->Run CMake + // is selected while this here is already running. + + // FIXME: Instead of aborting the second run here we could try to + // cancel the first one in the Build->Run CMake handler and then + // continue to here normally. This here could then be an Assert. + return; + } + + m_currentGuard = std::move(guard); if (m_allFiles.isEmpty()) m_buildDirManager.requestFilesystemScan();