diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index f435c270aaf..8181cef09f5 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1144,7 +1144,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er dd->m_projectExplorerSettings.environmentId = QUuid::createUuid(); int tmp = s->value(QLatin1String("ProjectExplorer/Settings/StopBeforeBuild"), Utils::HostOsInfo::isWindowsHost() ? 1 : 0).toInt(); - if (tmp < 0 || tmp > ProjectExplorerSettings::StopAll) + if (tmp < 0 || tmp > ProjectExplorerSettings::StopSameBuildDir) tmp = Utils::HostOsInfo::isWindowsHost() ? 1 : 0; dd->m_projectExplorerSettings.stopBeforeBuild = ProjectExplorerSettings::StopBeforeBuild(tmp); @@ -2225,10 +2225,36 @@ int ProjectExplorerPluginPrivate::queue(QList projects, QList ste if (m_projectExplorerSettings.stopBeforeBuild != ProjectExplorerSettings::StopNone && stepIds.contains(Constants::BUILDSTEPS_BUILD)) { - bool stopAll = (m_projectExplorerSettings.stopBeforeBuild == ProjectExplorerSettings::StopAll); + ProjectExplorerSettings::StopBeforeBuild stopCondition = m_projectExplorerSettings.stopBeforeBuild; const QList toStop - = Utils::filtered(m_outputPane->allRunControls(), [&projects, stopAll](RunControl *rc) { - return rc->isRunning() && (stopAll || projects.contains(rc->project())); + = Utils::filtered(m_outputPane->allRunControls(), [&projects, stopCondition](RunControl *rc) -> bool { + if (!rc->isRunning()) + return false; + + switch (stopCondition) { + case ProjectExplorerSettings::StopNone: + return false; + case ProjectExplorerSettings::StopAll: + return true; + case ProjectExplorerSettings::StopSameProject: + return projects.contains(rc->project()); + case ProjectExplorerSettings::StopSameBuildDir: + return Utils::contains(projects, [rc](Project *p) { + Target *t = p ? p->activeTarget() : nullptr; + BuildConfiguration *bc = t ? t->activeBuildConfiguration() : nullptr; + if (!bc) + return false; + if (!rc->runnable().is()) + return false; + if (!Utils::FileName::fromString(rc->runnable().as().executable).isChildOf(bc->buildDirectory())) + return false; + IDevice::ConstPtr device = rc->runnable().as().device; + if (device.isNull()) + device = DeviceKitInformation::device(t->kit()); + return !device.isNull() && device->type() == Core::Id(Constants::DESKTOP_DEVICE_TYPE); + }); + } + return false; // Can't get here! }); if (!toStop.isEmpty()) { diff --git a/src/plugins/projectexplorer/projectexplorersettings.h b/src/plugins/projectexplorer/projectexplorersettings.h index 046b90e88ac..a2759d66e3d 100644 --- a/src/plugins/projectexplorer/projectexplorersettings.h +++ b/src/plugins/projectexplorer/projectexplorersettings.h @@ -33,7 +33,7 @@ namespace Internal { class ProjectExplorerSettings { public: - enum StopBeforeBuild { StopNone = 0, StopSameProject = 1, StopAll = 2 }; + enum StopBeforeBuild { StopNone = 0, StopSameProject, StopAll, StopSameBuildDir }; bool buildBeforeDeploy = true; bool deployBeforeRun = true; diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.cpp b/src/plugins/projectexplorer/projectexplorersettingspage.cpp index 7605ddbbe24..12c6b10fdc0 100644 --- a/src/plugins/projectexplorer/projectexplorersettingspage.cpp +++ b/src/plugins/projectexplorer/projectexplorersettingspage.cpp @@ -109,7 +109,7 @@ ProjectExplorerSettings ProjectExplorerSettingsWidget::settings() const m_settings.useJom = m_ui.jomCheckbox->isChecked(); m_settings.prompToStopRunControl = m_ui.promptToStopRunControlCheckBox->isChecked(); m_settings.maxAppOutputLines = m_ui.maxAppOutputBox->value(); - m_settings.stopBeforeBuild = ProjectExplorerSettings::StopBeforeBuild(m_ui.stopBeforeBuildComboBox->currentIndex()); + m_settings.stopBeforeBuild = static_cast(m_ui.stopBeforeBuildComboBox->currentIndex()); return m_settings; } @@ -128,7 +128,7 @@ void ProjectExplorerSettingsWidget::setSettings(const ProjectExplorerSettings & m_ui.jomCheckbox->setChecked(m_settings.useJom); m_ui.promptToStopRunControlCheckBox->setChecked(m_settings.prompToStopRunControl); m_ui.maxAppOutputBox->setValue(m_settings.maxAppOutputLines); - m_ui.stopBeforeBuildComboBox->setCurrentIndex(pes.stopBeforeBuild); + m_ui.stopBeforeBuildComboBox->setCurrentIndex(static_cast(pes.stopBeforeBuild)); } QString ProjectExplorerSettingsWidget::projectsDirectory() const diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.ui b/src/plugins/projectexplorer/projectexplorersettingspage.ui index 01a131b63fa..7ea652cc174 100644 --- a/src/plugins/projectexplorer/projectexplorersettingspage.ui +++ b/src/plugins/projectexplorer/projectexplorersettingspage.ui @@ -202,6 +202,11 @@ All + + + Same Build Directory + +