From 6ccdf74965d7b8ced56ac41a05ade8d0208a42e7 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 5 Dec 2019 14:25:52 +0100 Subject: [PATCH] "Build & Run" settings: Add option to stop only the app to start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTCREATORBUG-16470 Change-Id: I95d28ebee7bbe4810a90a59959dcdef381668212 Reviewed-by: hjk Reviewed-by: André Hartmann --- src/plugins/projectexplorer/projectexplorer.cpp | 17 ++++++++++++----- .../projectexplorer/projectexplorersettings.h | 2 +- .../projectexplorersettingspage.cpp | 2 ++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 1ceb10c9867..e37ba8d0854 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -359,7 +359,7 @@ public: ProjectExplorerPluginPrivate(); void deploy(QList); - int queue(QList, QList stepIds); + int queue(QList, QList stepIds, const RunConfiguration *forRunConfig = nullptr); void updateContextMenuActions(); void updateLocationSubMenus(); void executeRunConfiguration(RunConfiguration *, Core::Id mode); @@ -1414,7 +1414,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er dd->m_projectExplorerSettings.environmentId = QUuid::createUuid(); int tmp = s->value(Constants::STOP_BEFORE_BUILD_SETTINGS_KEY, Utils::HostOsInfo::isWindowsHost() ? 1 : 0).toInt(); - if (tmp < 0 || tmp > int(StopBeforeBuild::SameBuildDir)) + if (tmp < 0 || tmp > int(StopBeforeBuild::SameApp)) tmp = Utils::HostOsInfo::isWindowsHost() ? 1 : 0; dd->m_projectExplorerSettings.stopBeforeBuild = StopBeforeBuild(tmp); dd->m_projectExplorerSettings.terminalMode = static_cast(s->value( @@ -2588,7 +2588,8 @@ QString ProjectExplorerPlugin::displayNameForStepId(Id stepId) return tr("Build", "Build step"); } -int ProjectExplorerPluginPrivate::queue(QList projects, QList stepIds) +int ProjectExplorerPluginPrivate::queue(QList projects, QList stepIds, + const RunConfiguration *forRunConfig) { if (!m_instance->saveModifiedFiles()) return -1; @@ -2596,8 +2597,10 @@ int ProjectExplorerPluginPrivate::queue(QList projects, QList ste if (m_projectExplorerSettings.stopBeforeBuild != StopBeforeBuild::None && stepIds.contains(Constants::BUILDSTEPS_BUILD)) { StopBeforeBuild stopCondition = m_projectExplorerSettings.stopBeforeBuild; + if (stopCondition == StopBeforeBuild::SameApp && !forRunConfig) + stopCondition = StopBeforeBuild::SameBuildDir; const QList toStop - = Utils::filtered(m_outputPane.allRunControls(), [&projects, stopCondition](RunControl *rc) -> bool { + = Utils::filtered(m_outputPane.allRunControls(), [&projects, stopCondition, forRunConfig](RunControl *rc) -> bool { if (!rc->isRunning()) return false; @@ -2621,6 +2624,10 @@ int ProjectExplorerPluginPrivate::queue(QList projects, QList ste device = DeviceKitAspect::device(t->kit()); return !device.isNull() && device->type() == Core::Id(Constants::DESKTOP_DEVICE_TYPE); }); + case StopBeforeBuild::SameApp: + QTC_ASSERT(forRunConfig, return false); + return forRunConfig->buildTargetInfo().targetFilePath + == rc->targetFilePath(); } return false; // Can't get here! }); @@ -2867,7 +2874,7 @@ void ProjectExplorerPlugin::runRunConfiguration(RunConfiguration *rc, } Project *pro = rc->target()->project(); - int queueCount = dd->queue(SessionManager::projectOrder(pro), stepIds); + int queueCount = dd->queue(SessionManager::projectOrder(pro), stepIds, rc); rc->target()->activeBuildConfiguration()->restrictNextBuild(nullptr); if (queueCount < 0) // something went wrong diff --git a/src/plugins/projectexplorer/projectexplorersettings.h b/src/plugins/projectexplorer/projectexplorersettings.h index d84bf3a4886..e3065a7f533 100644 --- a/src/plugins/projectexplorer/projectexplorersettings.h +++ b/src/plugins/projectexplorer/projectexplorersettings.h @@ -36,7 +36,7 @@ namespace Internal { enum class TerminalMode { On, Off, Smart }; enum class AppOutputPaneMode { FlashOnOutput, PopupOnOutput, PopupOnFirstOutput }; enum class BuildBeforeRunMode { Off, WholeProject, AppOnly }; -enum class StopBeforeBuild { None, SameProject, All, SameBuildDir }; +enum class StopBeforeBuild { None, SameProject, All, SameBuildDir, SameApp }; class ProjectExplorerSettings { diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.cpp b/src/plugins/projectexplorer/projectexplorersettingspage.cpp index ce8397816d2..ce737773a1c 100644 --- a/src/plugins/projectexplorer/projectexplorersettingspage.cpp +++ b/src/plugins/projectexplorer/projectexplorersettingspage.cpp @@ -80,6 +80,8 @@ ProjectExplorerSettingsWidget::ProjectExplorerSettingsWidget(QWidget *parent) : m_ui.stopBeforeBuildComboBox->addItem(tr("Same Project"), int(StopBeforeBuild::SameProject)); m_ui.stopBeforeBuildComboBox->addItem(tr("Same Build Directory"), int(StopBeforeBuild::SameBuildDir)); + m_ui.stopBeforeBuildComboBox->addItem(tr("Same Application"), + int(StopBeforeBuild::SameApp)); m_ui.buildBeforeDeployComboBox->addItem(tr("Do Not Build Anything"), int(BuildBeforeRunMode::Off)); m_ui.buildBeforeDeployComboBox->addItem(tr("Build the Whole Project"),