From ce4f57a01cff14d577db3c052d042f260e3d6d01 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 25 Jun 2019 17:07:25 +0200 Subject: [PATCH] Make it possible to continue with "Build All Projects" after errors The user might still want to get the second project built after the first one failed. Fixes: QTCREATORBUG-22140 Change-Id: I644e64ae2267b25e9804cb4a614edd5a3340a2e7 Reviewed-by: hjk --- src/plugins/projectexplorer/buildmanager.cpp | 29 ++++++++++++++++--- .../projectexplorer/projectexplorer.cpp | 6 ++++ .../projectexplorer/projectexplorersettings.h | 2 ++ .../projectexplorersettingspage.cpp | 2 ++ .../projectexplorersettingspage.ui | 8 +++++ 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp index eece545e07f..c67c2a5893c 100644 --- a/src/plugins/projectexplorer/buildmanager.cpp +++ b/src/plugins/projectexplorer/buildmanager.cpp @@ -80,6 +80,7 @@ public: bool m_skipDisabled = false; bool m_canceling = false; bool m_lastStepSucceeded = true; + bool m_allStepsSucceeded = true; BuildStep *m_currentBuildStep = nullptr; QString m_currentConfiguration; // used to decide if we are building a project to decide when to emit buildStateChanged(Project *) @@ -305,6 +306,7 @@ void BuildManager::startBuildQueue() d->m_progressFutureInterface->setProgressRange(0, d->m_maxProgress * 100); d->m_running = true; + d->m_allStepsSucceeded = true; d->m_progressFutureInterface->reportStarted(); nextStep(); } else { @@ -372,6 +374,7 @@ void BuildManager::nextBuildQueue() nextStep(); } else { // Build Failure + d->m_allStepsSucceeded = false; Target *t = d->m_currentBuildStep->target(); const QString projectName = d->m_currentBuildStep->project()->displayName(); const QString targetName = t->displayName(); @@ -382,10 +385,28 @@ void BuildManager::nextBuildQueue() .arg(targetName), BuildStep::OutputFormat::Stderr); } addToOutputWindow(tr("When executing step \"%1\"").arg(d->m_currentBuildStep->displayName()), BuildStep::OutputFormat::Stderr); - // NBS TODO fix in qtconcurrent - d->m_progressFutureInterface->setProgressValueAndText(d->m_progress*100, tr("Error while building/deploying project %1 (kit: %2)").arg(projectName, targetName)); - clearBuildQueue(); + bool abort = ProjectExplorerPlugin::projectExplorerSettings().abortBuildAllOnError; + if (!abort) { + while (!d->m_buildQueue.isEmpty() + && d->m_buildQueue.front()->target() == t) { + BuildStep * const nextStepForFailedTarget = d->m_buildQueue.takeFirst(); + disconnectOutput(nextStepForFailedTarget); + decrementActiveBuildSteps(nextStepForFailedTarget); + } + if (d->m_buildQueue.isEmpty()) + abort = true; + } + + if (abort) { + // NBS TODO fix in qtconcurrent + d->m_progressFutureInterface->setProgressValueAndText(d->m_progress * 100, + tr("Error while building/deploying project %1 (kit: %2)") + .arg(projectName, targetName)); + clearBuildQueue(); + } else { + nextStep(); + } } } @@ -438,7 +459,7 @@ void BuildManager::nextStep() delete d->m_progressFutureInterface; d->m_progressFutureInterface = nullptr; d->m_maxProgress = 0; - emit m_instance->buildQueueFinished(true); + emit m_instance->buildQueueFinished(d->m_allStepsSucceeded); } } diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index a4aa2f0ddb9..d5c5fb9ce53 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -253,6 +253,8 @@ const char TERMINAL_MODE_SETTINGS_KEY[] = "ProjectExplorer/Settings/TerminalMode const char CLOSE_FILES_WITH_PROJECT_SETTINGS_KEY[] = "ProjectExplorer/Settings/CloseFilesWithProject"; const char CLEAR_ISSUES_ON_REBUILD_SETTINGS_KEY[] = "ProjectExplorer/Settings/ClearIssuesOnRebuild"; +const char ABORT_BUILD_ALL_ON_ERROR_SETTINGS_KEY[] + = "ProjectExplorer/Settings/AbortBuildAllOnError"; } // namespace Constants @@ -1379,6 +1381,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er = s->value(Constants::CLOSE_FILES_WITH_PROJECT_SETTINGS_KEY, true).toBool(); dd->m_projectExplorerSettings.clearIssuesOnRebuild = s->value(Constants::CLEAR_ISSUES_ON_REBUILD_SETTINGS_KEY, true).toBool(); + dd->m_projectExplorerSettings.abortBuildAllOnError + = s->value(Constants::ABORT_BUILD_ALL_ON_ERROR_SETTINGS_KEY, true).toBool(); dd->m_projectExplorerSettings.buildDirectoryTemplate = s->value(Constants::DEFAULT_BUILD_DIRECTORY_TEMPLATE_KEY).toString(); if (dd->m_projectExplorerSettings.buildDirectoryTemplate.isEmpty()) @@ -1987,6 +1991,8 @@ void ProjectExplorerPluginPrivate::savePersistentSettings() dd->m_projectExplorerSettings.closeSourceFilesWithProject); s->setValue(Constants::CLEAR_ISSUES_ON_REBUILD_SETTINGS_KEY, dd->m_projectExplorerSettings.clearIssuesOnRebuild); + s->setValue(Constants::ABORT_BUILD_ALL_ON_ERROR_SETTINGS_KEY, + dd->m_projectExplorerSettings.abortBuildAllOnError); s->setValue(QLatin1String("ProjectExplorer/Settings/AutomaticallyCreateRunConfigurations"), dd->m_projectExplorerSettings.automaticallyCreateRunConfigurations); s->setValue(QLatin1String("ProjectExplorer/Settings/EnvironmentId"), dd->m_projectExplorerSettings.environmentId.toByteArray()); diff --git a/src/plugins/projectexplorer/projectexplorersettings.h b/src/plugins/projectexplorer/projectexplorersettings.h index 85e9a77abe1..a302ef787a5 100644 --- a/src/plugins/projectexplorer/projectexplorersettings.h +++ b/src/plugins/projectexplorer/projectexplorersettings.h @@ -50,6 +50,7 @@ public: bool addLibraryPathsToRunEnv = true; bool closeSourceFilesWithProject = true; bool clearIssuesOnRebuild = true; + bool abortBuildAllOnError = true; StopBeforeBuild stopBeforeBuild = StopBeforeBuild::StopNone; TerminalMode terminalMode = TerminalMode::Smart; QString buildDirectoryTemplate; @@ -75,6 +76,7 @@ inline bool operator==(const ProjectExplorerSettings &p1, const ProjectExplorerS && p1.terminalMode == p2.terminalMode && p1.closeSourceFilesWithProject == p2.closeSourceFilesWithProject && p1.clearIssuesOnRebuild == p2.clearIssuesOnRebuild + && p1.abortBuildAllOnError == p2.abortBuildAllOnError && p1.buildDirectoryTemplate == p2.buildDirectoryTemplate; } diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.cpp b/src/plugins/projectexplorer/projectexplorersettingspage.cpp index 73f622aedf0..78727aa08b6 100644 --- a/src/plugins/projectexplorer/projectexplorersettingspage.cpp +++ b/src/plugins/projectexplorer/projectexplorersettingspage.cpp @@ -108,6 +108,7 @@ ProjectExplorerSettings ProjectExplorerSettingsWidget::settings() const m_settings.terminalMode = static_cast(m_ui.terminalModeComboBox->currentIndex()); m_settings.closeSourceFilesWithProject = m_ui.closeSourceFilesCheckBox->isChecked(); m_settings.clearIssuesOnRebuild = m_ui.clearIssuesCheckBox->isChecked(); + m_settings.abortBuildAllOnError = m_ui.abortBuildAllOnErrorCheckBox->isChecked(); m_settings.buildDirectoryTemplate = buildDirectoryTemplate(); return m_settings; } @@ -126,6 +127,7 @@ void ProjectExplorerSettingsWidget::setSettings(const ProjectExplorerSettings & m_ui.terminalModeComboBox->setCurrentIndex(static_cast(m_settings.terminalMode)); m_ui.closeSourceFilesCheckBox->setChecked(m_settings.closeSourceFilesWithProject); m_ui.clearIssuesCheckBox->setChecked(m_settings.clearIssuesOnRebuild); + m_ui.abortBuildAllOnErrorCheckBox->setChecked(m_settings.abortBuildAllOnError); setBuildDirectoryTemplate(pes.buildDirectoryTemplate); } diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.ui b/src/plugins/projectexplorer/projectexplorersettingspage.ui index 448ad3655b4..dc826601127 100644 --- a/src/plugins/projectexplorer/projectexplorersettingspage.ui +++ b/src/plugins/projectexplorer/projectexplorersettingspage.ui @@ -141,6 +141,13 @@ + + + + Abort on error when building all projects + + + @@ -302,6 +309,7 @@ promptToStopRunControlCheckBox addLibraryPathsToRunEnvCheckBox clearIssuesCheckBox + abortBuildAllOnErrorCheckBox