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 <tim.jenssen@qt.io>
This commit is contained in:
Claus Steuer
2017-06-19 17:29:35 +02:00
committed by Tobias Hunger
parent 523439d71b
commit 8542ebcd5d
2 changed files with 16 additions and 3 deletions

View File

@@ -267,7 +267,7 @@ void CMakeBuildStep::run(QFutureInterface<bool> &fi)
m_runTrigger = connect(bc, &CMakeBuildConfiguration::dataAvailable, m_runTrigger = connect(bc, &CMakeBuildConfiguration::dataAvailable,
this, [this, &fi]() { runImpl(fi); }); this, [this, &fi]() { runImpl(fi); });
m_errorTrigger = connect(bc, &CMakeBuildConfiguration::errorOccured, m_errorTrigger = connect(bc, &CMakeBuildConfiguration::errorOccured,
this, [this, &fi]() { reportRunResult(fi, false); }); this, [this, &fi](const QString& em) { handleCMakeError(fi, em); });
} else { } else {
runImpl(fi); runImpl(fi);
} }
@@ -276,10 +276,21 @@ void CMakeBuildStep::run(QFutureInterface<bool> &fi)
void CMakeBuildStep::runImpl(QFutureInterface<bool> &fi) void CMakeBuildStep::runImpl(QFutureInterface<bool> &fi)
{ {
// Do the actual build: // Do the actual build:
disconnectTriggers();
AbstractProcessStep::run(fi);
}
void CMakeBuildStep::handleCMakeError(QFutureInterface<bool> &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_runTrigger);
disconnect(m_errorTrigger); disconnect(m_errorTrigger);
AbstractProcessStep::run(fi);
} }
BuildStepConfigWidget *CMakeBuildStep::createConfigWidget() BuildStepConfigWidget *CMakeBuildStep::createConfigWidget()

View File

@@ -104,6 +104,8 @@ private:
void ctor(ProjectExplorer::BuildStepList *bsl); void ctor(ProjectExplorer::BuildStepList *bsl);
void runImpl(QFutureInterface<bool> &fi); void runImpl(QFutureInterface<bool> &fi);
void handleCMakeError(QFutureInterface<bool> &fi, const QString& errorMessage);
void disconnectTriggers();
void handleBuildTargetChanges(); void handleBuildTargetChanges();
CMakeRunConfiguration *targetsActiveRunConfiguration() const; CMakeRunConfiguration *targetsActiveRunConfiguration() const;