From f2012bca8f3d4f5617559dc3227c4cc412b4713e Mon Sep 17 00:00:00 2001
From: hjk <hjk@theqtcompany.com>
Date: Wed, 27 Jan 2016 14:07:23 +0100
Subject: [PATCH] Analyzer: Remove explicit working directory storage in run
 control

Instead, use the one in its (Standard)Runnable.

The change is mechanical except to the fallback to the project directory
which was introduced in 8150209f to keep some compatibility with the previous
setup of the Android runner which created and copied the fallback value around
and ignored it in the end. Not producing the fallback value is less effort.

Change-Id: Ie04da570f0f9fbc1d048f2eacaed522f7253afa3
Reviewed-by: hjk <hjk@theqtcompany.com>
---
 .../analyzerbase/analyzerruncontrol.cpp        | 18 ------------------
 src/plugins/analyzerbase/analyzerruncontrol.h  |  6 ------
 .../qmlprofilerruncontrolfactory.cpp           |  2 +-
 src/plugins/valgrind/valgrindengine.cpp        |  1 -
 src/plugins/valgrind/valgrindplugin.cpp        |  2 --
 .../valgrind/valgrindruncontrolfactory.cpp     |  3 ---
 6 files changed, 1 insertion(+), 31 deletions(-)

diff --git a/src/plugins/analyzerbase/analyzerruncontrol.cpp b/src/plugins/analyzerbase/analyzerruncontrol.cpp
index 93819b7d7d7..b7769e8db92 100644
--- a/src/plugins/analyzerbase/analyzerruncontrol.cpp
+++ b/src/plugins/analyzerbase/analyzerruncontrol.cpp
@@ -52,14 +52,6 @@ AnalyzerRunControl::AnalyzerRunControl(RunConfiguration *runConfiguration, Core:
 {
     setIcon(Icons::ANALYZER_CONTROL_START);
 
-    if (runConfiguration) {
-        setDisplayName(runConfiguration->displayName());
-        if (auto aspect = runConfiguration->extraAspect<WorkingDirectoryAspect>())
-            m_workingDirectory = aspect->workingDirectory().toString();
-        if (m_workingDirectory.isEmpty())
-            m_workingDirectory = runConfiguration->target()->project()->projectDirectory().toString();
-    }
-
     connect(this, &AnalyzerRunControl::finished,
             this, &AnalyzerRunControl::runControlFinished);
     connect(AnalyzerManager::stopAction(), &QAction::triggered,
@@ -88,11 +80,6 @@ void AnalyzerRunControl::runControlFinished()
     AnalyzerManager::handleToolFinished();
 }
 
-QString AnalyzerRunControl::workingDirectory() const
-{
-    return m_workingDirectory;
-}
-
 void AnalyzerRunControl::start()
 {
     AnalyzerManager::handleToolStarted();
@@ -118,9 +105,4 @@ bool AnalyzerRunControl::isRunning() const
     return m_isRunning;
 }
 
-void AnalyzerRunControl::setWorkingDirectory(const QString &workingDirectory)
-{
-    m_workingDirectory = workingDirectory;
-}
-
 } // namespace Analyzer
diff --git a/src/plugins/analyzerbase/analyzerruncontrol.h b/src/plugins/analyzerbase/analyzerruncontrol.h
index 30983dec5c9..51cfe99e716 100644
--- a/src/plugins/analyzerbase/analyzerruncontrol.h
+++ b/src/plugins/analyzerbase/analyzerruncontrol.h
@@ -70,9 +70,6 @@ public:
     StopResult stop();
     bool isRunning() const;
 
-    QString workingDirectory() const;
-    void setWorkingDirectory(const QString &workingDirectory);
-
 public slots:
     virtual void logApplicationMessage(const QString &, Utils::OutputFormat) {}
 
@@ -89,9 +86,6 @@ private:
 
 protected:
     bool m_isRunning;
-
-private:
-    QString m_workingDirectory;
 };
 } // namespace Analyzer
 
diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp
index cf9754099f7..65c20ba11ab 100644
--- a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp
@@ -103,7 +103,7 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat
     LocalQmlProfilerRunner::Configuration conf;
     conf.executable = runnable.executable;
     conf.executableArguments = runnable.commandLineArguments;
-    conf.workingDirectory = runControl->workingDirectory();
+    conf.workingDirectory = runnable.workingDirectory;
     conf.socket = connection.analyzerSocket;
     if (EnvironmentAspect *environment = runConfiguration->extraAspect<EnvironmentAspect>())
         conf.environment = environment->environment();
diff --git a/src/plugins/valgrind/valgrindengine.cpp b/src/plugins/valgrind/valgrindengine.cpp
index 5d23824a9f6..3b7fd77202f 100644
--- a/src/plugins/valgrind/valgrindengine.cpp
+++ b/src/plugins/valgrind/valgrindengine.cpp
@@ -85,7 +85,6 @@ bool ValgrindRunControl::startEngine()
 
     StandardRunnable debuggee = runnable();
     // FIXME: Consolidate:
-    debuggee.workingDirectory = workingDirectory();
     debuggee.environment = m_environment;
     debuggee.runMode = m_localRunMode;
 
diff --git a/src/plugins/valgrind/valgrindplugin.cpp b/src/plugins/valgrind/valgrindplugin.cpp
index bdf5a2b557f..fb90fca0e66 100644
--- a/src/plugins/valgrind/valgrindplugin.cpp
+++ b/src/plugins/valgrind/valgrindplugin.cpp
@@ -199,7 +199,6 @@ void ValgrindPlugin::extensionsInitialized()
         connection.connParams = dlg.sshParams();
         rc->setConnection(connection);
         rc->setDisplayName(runnable.executable);
-        rc->setWorkingDirectory(runnable.workingDirectory);
         rc->setCustomStart();
         ProjectExplorerPlugin::startRunControl(rc, MEMCHECK_RUN_MODE);
     });
@@ -224,7 +223,6 @@ void ValgrindPlugin::extensionsInitialized()
         connection.connParams = dlg.sshParams();
         rc->setConnection(connection);
         rc->setDisplayName(runnable.executable);
-        rc->setWorkingDirectory(runnable.workingDirectory);
         rc->setCustomStart();
         ProjectExplorerPlugin::startRunControl(rc, CALLGRIND_RUN_MODE);
     });
diff --git a/src/plugins/valgrind/valgrindruncontrolfactory.cpp b/src/plugins/valgrind/valgrindruncontrolfactory.cpp
index c2cfc57ae38..af98c5dd1c8 100644
--- a/src/plugins/valgrind/valgrindruncontrolfactory.cpp
+++ b/src/plugins/valgrind/valgrindruncontrolfactory.cpp
@@ -78,13 +78,11 @@ RunControl *ValgrindRunControlFactory::create(RunConfiguration *runConfiguration
     Utils::Environment environment;
     StandardRunnable runnable;
     AnalyzerConnection connection;
-    QString workingDirectory;
     Runnable rcRunnable = runConfiguration->runnable();
     QTC_ASSERT(rcRunnable.is<StandardRunnable>(), return 0);
     auto stdRunnable = runConfiguration->runnable().as<StandardRunnable>();
     if (device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
         environment = stdRunnable.environment;
-        workingDirectory = stdRunnable.workingDirectory;
         runnable.executable = stdRunnable.executable;
         runnable.commandLineArguments = stdRunnable.commandLineArguments;
         QTcpServer server;
@@ -105,7 +103,6 @@ RunControl *ValgrindRunControlFactory::create(RunConfiguration *runConfiguration
     runControl->setConnection(connection);
     runControl->setLocalRunMode(localRunMode);
     runControl->setEnvironment(environment);
-    runControl->setWorkingDirectory(workingDirectory);
     return runControl;
 }
 
-- 
GitLab