From 8542ebcd5dd312aa3038d0b70c861dc05c71333a Mon Sep 17 00:00:00 2001 From: Claus Steuer Date: Mon, 19 Jun 2017 17:29:35 +0200 Subject: [PATCH] CMake: Do not react to builds in the background If an error occurs while persisting or updating the cmake state, the build might continue for a while in the background. CMakeBuildStep does not disconnect the Error/Run-Trigger when an error is signaled by the CMakeBuildConfiguration. Instead it reports the build as finished (with error). The BuildManager then disconnects the output and runs the next item in the build queue (if any). However the cmake step might still be alive and emits the dataAvailable signal which then triggers the build process. Task-number: QTCREATORBUG-18382 Change-Id: I956133fe8c6f7de58b9f842b231c70d24778b1e0 Reviewed-by: Tim Jenssen --- .../cmakeprojectmanager/cmakebuildstep.cpp | 17 ++++++++++++++--- .../cmakeprojectmanager/cmakebuildstep.h | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp index d87a538f98b..4bc51dd42ec 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp @@ -267,7 +267,7 @@ void CMakeBuildStep::run(QFutureInterface &fi) m_runTrigger = connect(bc, &CMakeBuildConfiguration::dataAvailable, this, [this, &fi]() { runImpl(fi); }); m_errorTrigger = connect(bc, &CMakeBuildConfiguration::errorOccured, - this, [this, &fi]() { reportRunResult(fi, false); }); + this, [this, &fi](const QString& em) { handleCMakeError(fi, em); }); } else { runImpl(fi); } @@ -276,10 +276,21 @@ void CMakeBuildStep::run(QFutureInterface &fi) void CMakeBuildStep::runImpl(QFutureInterface &fi) { // Do the actual build: + disconnectTriggers(); + AbstractProcessStep::run(fi); +} + +void CMakeBuildStep::handleCMakeError(QFutureInterface &fi, const QString& errorMessage) +{ + disconnectTriggers(); + AbstractProcessStep::stdError(tr("Error parsing CMake: %1\n").arg(errorMessage)); + reportRunResult(fi, false); +} + +void CMakeBuildStep::disconnectTriggers() +{ disconnect(m_runTrigger); disconnect(m_errorTrigger); - - AbstractProcessStep::run(fi); } BuildStepConfigWidget *CMakeBuildStep::createConfigWidget() diff --git a/src/plugins/cmakeprojectmanager/cmakebuildstep.h b/src/plugins/cmakeprojectmanager/cmakebuildstep.h index 70d89c87830..08cee9a01cb 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildstep.h +++ b/src/plugins/cmakeprojectmanager/cmakebuildstep.h @@ -104,6 +104,8 @@ private: void ctor(ProjectExplorer::BuildStepList *bsl); void runImpl(QFutureInterface &fi); + void handleCMakeError(QFutureInterface &fi, const QString& errorMessage); + void disconnectTriggers(); void handleBuildTargetChanges(); CMakeRunConfiguration *targetsActiveRunConfiguration() const;