From a27cd125385a43b0440b33433c993c6690899a0a Mon Sep 17 00:00:00 2001
From: Tobias Hunger <tobias.hunger@theqtcompany.com>
Date: Tue, 10 Nov 2015 17:08:16 +0100
Subject: [PATCH] ProjectExplorer: Do not kill applications when deploying

Only kill applications when adding build-steps, not for deploy-steps.
This is more in line with what the documentation says.

Task-number: QTCREATORBUG-15281
Change-Id: Iaa8cfb3efb79645ff29d0c67b24636aefa1d7d3e
Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
---
 src/plugins/projectexplorer/projectexplorer.cpp | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index e2e18fc08c6..f0c9c85599e 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -1161,10 +1161,8 @@ 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();
-    dd->m_projectExplorerSettings.stopBeforeBuild = ProjectExplorerSettings::StopBeforeBuild(tmp);
     if (tmp < 0 || tmp > ProjectExplorerSettings::StopAll)
         tmp = Utils::HostOsInfo::isWindowsHost() ? 1 : 0;
-
     dd->m_projectExplorerSettings.stopBeforeBuild = ProjectExplorerSettings::StopBeforeBuild(tmp);
 
     connect(dd->m_sessionManagerAction, &QAction::triggered,
@@ -2294,14 +2292,13 @@ int ProjectExplorerPluginPrivate::queue(QList<Project *> projects, QList<Id> ste
     if (!m_instance->saveModifiedFiles())
         return -1;
 
-    if (m_projectExplorerSettings.stopBeforeBuild != ProjectExplorerSettings::StopNone) {
-        QList<RunControl *> toStop;
-        foreach (RunControl *rc, m_outputPane->allRunControls()) {
-            if (rc->isRunning()
-                    && (m_projectExplorerSettings.stopBeforeBuild == ProjectExplorerSettings::StopAll
-                        || projects.contains(rc->project())))
-                toStop << rc;
-        }
+    if (m_projectExplorerSettings.stopBeforeBuild != ProjectExplorerSettings::StopNone
+            && stepIds.contains(Constants::BUILDSTEPS_BUILD)) {
+        bool stopAll = (m_projectExplorerSettings.stopBeforeBuild == ProjectExplorerSettings::StopAll);
+        const QList<RunControl *> toStop
+                = Utils::filtered(m_outputPane->allRunControls(), [&projects, stopAll](RunControl *rc) {
+                                      return rc->isRunning() && (stopAll || projects.contains(rc->project()));
+                                  });
 
         if (!toStop.isEmpty()) {
             bool stopThem = true;
-- 
GitLab