summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2017-02-27 17:25:58 +0100
committerTobias Hunger <tobias.hunger@qt.io>2017-03-01 12:46:59 +0000
commite07c6383d7e6bc7f44e0820fa1a33a9470397a60 (patch)
tree1c3da78e0f6872e1d4de5874d60fae83672b208e
parent329db5f4cc1fced14aeccbd2f8f580ec8c2d26a3 (diff)
downloadqt-creator-e07c6383d7e6bc7f44e0820fa1a33a9470397a60.tar.gz
ProjectExplorer: Unify RunControl setup/teardown
Provide protected methods in RunControl to handle the notification of when the RunControl starts and stops. Use these helpers to move the isRunning() method into the RunConfiguration itself instead of reimplementing it everywhere. Change-Id: Ia8de42f7a6a14a049870d4e7fcb9af6756c2caa4 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io> Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
-rw-r--r--src/plugins/android/androidruncontrol.cpp12
-rw-r--r--src/plugins/android/androidruncontrol.h2
-rw-r--r--src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp22
-rw-r--r--src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h2
-rw-r--r--src/plugins/debugger/debuggerruncontrol.cpp23
-rw-r--r--src/plugins/debugger/debuggerruncontrol.h2
-rw-r--r--src/plugins/ios/iosruncontrol.cpp12
-rw-r--r--src/plugins/ios/iosruncontrol.h2
-rw-r--r--src/plugins/nim/project/nimruncontrol.cpp12
-rw-r--r--src/plugins/nim/project/nimruncontrol.h2
-rw-r--r--src/plugins/projectexplorer/localapplicationruncontrol.cpp18
-rw-r--r--src/plugins/projectexplorer/runconfiguration.cpp26
-rw-r--r--src/plugins/projectexplorer/runconfiguration.h13
-rw-r--r--src/plugins/pythoneditor/pythoneditorplugin.cpp15
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp27
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerruncontrol.h1
-rw-r--r--src/plugins/remotelinux/remotelinuxruncontrol.cpp14
-rw-r--r--src/plugins/remotelinux/remotelinuxruncontrol.h1
-rw-r--r--src/plugins/valgrind/valgrindengine.cpp15
-rw-r--r--src/plugins/valgrind/valgrindengine.h2
-rw-r--r--src/plugins/winrt/winrtruncontrol.cpp10
-rw-r--r--src/plugins/winrt/winrtruncontrol.h1
22 files changed, 78 insertions, 156 deletions
diff --git a/src/plugins/android/androidruncontrol.cpp b/src/plugins/android/androidruncontrol.cpp
index b7d8c92004..7c5d815a16 100644
--- a/src/plugins/android/androidruncontrol.cpp
+++ b/src/plugins/android/androidruncontrol.cpp
@@ -41,7 +41,6 @@ namespace Internal {
AndroidRunControl::AndroidRunControl(AndroidRunConfiguration *rc)
: RunControl(rc, ProjectExplorer::Constants::NORMAL_RUN_MODE)
, m_runner(new AndroidRunner(this, rc, ProjectExplorer::Constants::NORMAL_RUN_MODE))
- , m_running(false)
{
setRunnable(m_runner->runnable());
setIcon(Utils::Icons::RUN_SMALL_TOOLBAR);
@@ -54,8 +53,7 @@ AndroidRunControl::~AndroidRunControl()
void AndroidRunControl::start()
{
- m_running = true;
- emit started();
+ reportApplicationStart();
disconnect(m_runner, 0, this, 0);
connect(m_runner, &AndroidRunner::remoteErrorOutput,
@@ -79,8 +77,7 @@ void AndroidRunControl::handleRemoteProcessFinished(const QString &error)
{
appendMessage(error, Utils::ErrorMessageFormat);
disconnect(m_runner, 0, this, 0);
- m_running = false;
- emit finished();
+ reportApplicationStop();
}
void AndroidRunControl::handleRemoteOutput(const QString &output)
@@ -93,11 +90,6 @@ void AndroidRunControl::handleRemoteErrorOutput(const QString &output)
appendMessage(output, Utils::StdErrFormatSameLine);
}
-bool AndroidRunControl::isRunning() const
-{
- return m_running;
-}
-
QString AndroidRunControl::displayName() const
{
return m_runner->displayName();
diff --git a/src/plugins/android/androidruncontrol.h b/src/plugins/android/androidruncontrol.h
index 472856f7d7..5dc9fffb6b 100644
--- a/src/plugins/android/androidruncontrol.h
+++ b/src/plugins/android/androidruncontrol.h
@@ -43,7 +43,6 @@ public:
void start() override;
StopResult stop() override;
- bool isRunning() const override;
QString displayName() const override;
private:
@@ -52,7 +51,6 @@ private:
void handleRemoteErrorOutput(const QString &output);
AndroidRunner *const m_runner;
- bool m_running;
};
} // namespace Internal
diff --git a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp
index 544832013a..019b0632b5 100644
--- a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp
+++ b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp
@@ -469,7 +469,7 @@ void ClangStaticAnalyzerRunControl::start()
m_success = false;
emit starting();
- QTC_ASSERT(m_projectInfo.isValid(), emit finished(); return);
+ QTC_ASSERT(m_projectInfo.isValid(), reportApplicationStop(); return);
const Utils::FileName projectFile = m_projectInfo.project()->projectFilePath();
appendMessage(tr("Running Clang Static Analyzer on %1").arg(projectFile.toUserOutput())
+ QLatin1Char('\n'), Utils::NormalMessageFormat);
@@ -485,7 +485,7 @@ void ClangStaticAnalyzerRunControl::start()
appendMessage(errorMessage + QLatin1Char('\n'), Utils::ErrorMessageFormat);
TaskHub::addTask(Task::Error, errorMessage, Debugger::Constants::ANALYZERTASK_ID);
TaskHub::requestPopup();
- emit finished();
+ reportApplicationStop();
return;
}
@@ -522,7 +522,7 @@ void ClangStaticAnalyzerRunControl::start()
appendMessage(errorMessage + QLatin1Char('\n'), Utils::ErrorMessageFormat);
TaskHub::addTask(Task::Error, errorMessage, Debugger::Constants::ANALYZERTASK_ID);
TaskHub::requestPopup();
- emit finished();
+ reportApplicationStop();
return;
}
m_clangLogFileDir = temporaryDir.path();
@@ -550,16 +550,15 @@ void ClangStaticAnalyzerRunControl::start()
qCDebug(LOG) << "Environment:" << m_environment;
m_runners.clear();
const int parallelRuns = ClangStaticAnalyzerSettings::instance()->simultaneousProcesses();
- QTC_ASSERT(parallelRuns >= 1, emit finished(); return);
+ QTC_ASSERT(parallelRuns >= 1, reportApplicationStop(); return);
m_success = true;
- m_running = true;
if (m_unitsToProcess.isEmpty()) {
finalize();
return;
}
- emit started();
+ reportApplicationStart();
while (m_runners.size() < parallelRuns && !m_unitsToProcess.isEmpty())
analyzeNextFile();
@@ -578,16 +577,10 @@ RunControl::StopResult ClangStaticAnalyzerRunControl::stop()
appendMessage(tr("Clang Static Analyzer stopped by user.") + QLatin1Char('\n'),
Utils::NormalMessageFormat);
m_progress.reportFinished();
- m_running = false;
- emit finished();
+ reportApplicationStop();
return RunControl::StoppedSynchronously;
}
-bool ClangStaticAnalyzerRunControl::isRunning() const
-{
- return m_running;
-}
-
void ClangStaticAnalyzerRunControl::analyzeNextFile()
{
if (m_progress.isFinished())
@@ -701,8 +694,7 @@ void ClangStaticAnalyzerRunControl::finalize()
}
m_progress.reportFinished();
- m_running = false;
- emit finished();
+ reportApplicationStop();
}
} // namespace Internal
diff --git a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h
index ce974bac37..9776de88d2 100644
--- a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h
+++ b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h
@@ -58,7 +58,6 @@ public:
void start() override;
StopResult stop() override;
- bool isRunning() const override;
bool success() const { return m_success; } // For testing.
bool supportsReRunning() const override { return false; }
@@ -95,7 +94,6 @@ private:
int m_filesAnalyzed;
int m_filesNotAnalyzed;
bool m_success;
- bool m_running = false;
};
} // namespace Internal
diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp
index 426b36df04..49e85e9840 100644
--- a/src/plugins/debugger/debuggerruncontrol.cpp
+++ b/src/plugins/debugger/debuggerruncontrol.cpp
@@ -112,8 +112,7 @@ DebuggerRunControl *createHelper(RunConfiguration *runConfig, Internal::Debugger
DebuggerRunControl::DebuggerRunControl(RunConfiguration *runConfig, DebuggerEngine *engine)
: RunControl(runConfig, DebugRunMode),
- m_engine(engine),
- m_running(false)
+ m_engine(engine)
{
setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL_TOOLBAR);
connect(this, &RunControl::finished, this, &DebuggerRunControl::handleFinished);
@@ -192,8 +191,8 @@ void DebuggerRunControl::start()
&& m_engine->runParameters().inferior.executable.isEmpty()
&& m_engine->runParameters().interpreter.isEmpty()) {
appendMessage(tr("No executable specified.") + QLatin1Char('\n'), ErrorMessageFormat);
- emit started();
- emit finished();
+ reportApplicationStart();
+ reportApplicationStop();
return;
}
@@ -226,20 +225,18 @@ void DebuggerRunControl::start()
// We might get a synchronous startFailed() notification on Windows,
// when launching the process fails. Emit a proper finished() sequence.
- emit started();
- m_running = true;
+ reportApplicationStart();
m_engine->startDebugger(this);
- if (m_running)
+ if (isRunning())
appendMessage(tr("Debugging starts") + QLatin1Char('\n'), NormalMessageFormat);
}
void DebuggerRunControl::startFailed()
{
appendMessage(tr("Debugging has failed") + QLatin1Char('\n'), NormalMessageFormat);
- m_running = false;
- emit finished();
+ reportApplicationStop();
m_engine->handleStartFailed();
}
@@ -288,8 +285,7 @@ RunControl::StopResult DebuggerRunControl::stop()
void DebuggerRunControl::debuggingFinished()
{
- m_running = false;
- emit finished();
+ reportApplicationStop();
}
void DebuggerRunControl::showMessage(const QString &msg, int channel)
@@ -297,11 +293,6 @@ void DebuggerRunControl::showMessage(const QString &msg, int channel)
m_engine->showMessage(msg, channel);
}
-bool DebuggerRunControl::isRunning() const
-{
- return m_running;
-}
-
DebuggerStartParameters &DebuggerRunControl::startParameters()
{
return m_engine->runParameters();
diff --git a/src/plugins/debugger/debuggerruncontrol.h b/src/plugins/debugger/debuggerruncontrol.h
index 9a98dbdd2a..f2c61e2105 100644
--- a/src/plugins/debugger/debuggerruncontrol.h
+++ b/src/plugins/debugger/debuggerruncontrol.h
@@ -69,7 +69,6 @@ public:
void start() override;
bool promptToStop(bool *prompt = 0) const override;
StopResult stop() override; // Called from SnapshotWindow.
- bool isRunning() const override;
QString displayName() const override;
bool supportsReRunning() const override;
void handleApplicationOutput(const QString &msg, int channel);
@@ -104,7 +103,6 @@ private:
Internal::DebuggerEngine *engine);
Internal::DebuggerEngine *m_engine;
- bool m_running;
OutputProcessor *m_outputProcessor = 0;
};
diff --git a/src/plugins/ios/iosruncontrol.cpp b/src/plugins/ios/iosruncontrol.cpp
index cdfa5cf9ac..1699704532 100644
--- a/src/plugins/ios/iosruncontrol.cpp
+++ b/src/plugins/ios/iosruncontrol.cpp
@@ -40,7 +40,6 @@ namespace Internal {
IosRunControl::IosRunControl(IosRunConfiguration *rc)
: RunControl(rc, ProjectExplorer::Constants::NORMAL_RUN_MODE)
, m_runner(new IosRunner(this, rc, false, QmlDebug::NoQmlDebugServices))
- , m_running(false)
{
setIcon(Utils::Icons::RUN_SMALL_TOOLBAR);
}
@@ -52,8 +51,7 @@ IosRunControl::~IosRunControl()
void IosRunControl::start()
{
- m_running = true;
- emit started();
+ reportApplicationStart();
disconnect(m_runner, 0, this, 0);
connect(m_runner, &IosRunner::errorMsg,
@@ -79,8 +77,7 @@ void IosRunControl::handleRemoteProcessFinished(bool cleanEnd)
else
appendMessage(tr("Run ended."), Utils::NormalMessageFormat);
disconnect(m_runner, 0, this, 0);
- m_running = false;
- emit finished();
+ reportApplicationStop();
}
void IosRunControl::handleRemoteOutput(const QString &output)
@@ -93,11 +90,6 @@ void IosRunControl::handleRemoteErrorOutput(const QString &output)
appendMessage(output, Utils::StdErrFormat);
}
-bool IosRunControl::isRunning() const
-{
- return m_running;
-}
-
QString IosRunControl::displayName() const
{
return m_runner->displayName();
diff --git a/src/plugins/ios/iosruncontrol.h b/src/plugins/ios/iosruncontrol.h
index 082d94669f..b60f73d452 100644
--- a/src/plugins/ios/iosruncontrol.h
+++ b/src/plugins/ios/iosruncontrol.h
@@ -44,7 +44,6 @@ public:
void start() override;
StopResult stop() override;
- bool isRunning() const override;
QString displayName() const override;
private:
@@ -53,7 +52,6 @@ private:
void handleRemoteErrorOutput(const QString &output);
IosRunner *const m_runner;
- bool m_running;
};
} // namespace Internal
diff --git a/src/plugins/nim/project/nimruncontrol.cpp b/src/plugins/nim/project/nimruncontrol.cpp
index baff9ad6f3..b0c4da0022 100644
--- a/src/plugins/nim/project/nimruncontrol.cpp
+++ b/src/plugins/nim/project/nimruncontrol.cpp
@@ -39,7 +39,6 @@ namespace Nim {
NimRunControl::NimRunControl(NimRunConfiguration *rc, Core::Id mode)
: RunControl(rc, mode)
- , m_running(false)
, m_runnable(rc->runnable().as<StandardRunnable>())
{
connect(&m_applicationLauncher, &ApplicationLauncher::appendMessage,
@@ -54,8 +53,7 @@ NimRunControl::NimRunControl(NimRunConfiguration *rc, Core::Id mode)
void NimRunControl::start()
{
- emit started();
- m_running = true;
+ reportApplicationStart();
m_applicationLauncher.start(m_runnable);
setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID()));
}
@@ -66,11 +64,6 @@ ProjectExplorer::RunControl::StopResult NimRunControl::stop()
return StoppedSynchronously;
}
-bool NimRunControl::isRunning() const
-{
- return m_running;
-}
-
void NimRunControl::processStarted()
{
// Console processes only know their pid after being started
@@ -79,7 +72,6 @@ void NimRunControl::processStarted()
void NimRunControl::processExited(int exitCode, QProcess::ExitStatus status)
{
- m_running = false;
setApplicationProcessHandle(ProcessHandle());
QString msg;
if (status == QProcess::CrashExit) {
@@ -90,7 +82,7 @@ void NimRunControl::processExited(int exitCode, QProcess::ExitStatus status)
.arg(QDir::toNativeSeparators(m_runnable.executable)).arg(exitCode);
}
appendMessage(msg + QLatin1Char('\n'), NormalMessageFormat);
- emit finished();
+ reportApplicationStop();
}
void NimRunControl::slotAppendMessage(const QString &err, OutputFormat format)
diff --git a/src/plugins/nim/project/nimruncontrol.h b/src/plugins/nim/project/nimruncontrol.h
index 530361e2ef..0eba08e8ce 100644
--- a/src/plugins/nim/project/nimruncontrol.h
+++ b/src/plugins/nim/project/nimruncontrol.h
@@ -43,7 +43,6 @@ public:
void start() override;
StopResult stop() override;
- bool isRunning() const override;
private:
void processStarted();
@@ -51,7 +50,6 @@ private:
void slotAppendMessage(const QString &err, Utils::OutputFormat isError);
ProjectExplorer::ApplicationLauncher m_applicationLauncher;
- bool m_running;
ProjectExplorer::StandardRunnable m_runnable;
};
diff --git a/src/plugins/projectexplorer/localapplicationruncontrol.cpp b/src/plugins/projectexplorer/localapplicationruncontrol.cpp
index 22b021ed0a..44826940ea 100644
--- a/src/plugins/projectexplorer/localapplicationruncontrol.cpp
+++ b/src/plugins/projectexplorer/localapplicationruncontrol.cpp
@@ -50,14 +50,12 @@ public:
void start() override;
StopResult stop() override;
- bool isRunning() const override;
private:
void processStarted();
void processExited(int exitCode, QProcess::ExitStatus status);
ApplicationLauncher m_applicationLauncher;
- bool m_running = false;
};
LocalApplicationRunControl::LocalApplicationRunControl(RunConfiguration *rc, Core::Id mode)
@@ -79,17 +77,16 @@ void LocalApplicationRunControl::start()
{
QTC_ASSERT(runnable().is<StandardRunnable>(), return);
auto r = runnable().as<StandardRunnable>();
- emit started();
+ reportApplicationStart();
if (r.executable.isEmpty()) {
appendMessage(tr("No executable specified.") + QLatin1Char('\n'), Utils::ErrorMessageFormat);
- emit finished();
+ reportApplicationStop();
} else if (!QFileInfo::exists(r.executable)) {
appendMessage(tr("Executable %1 does not exist.")
.arg(QDir::toNativeSeparators(r.executable)) + QLatin1Char('\n'),
Utils::ErrorMessageFormat);
- emit finished();
+ reportApplicationStop();
} else {
- m_running = true;
QString msg = tr("Starting %1...").arg(QDir::toNativeSeparators(r.executable)) + QLatin1Char('\n');
appendMessage(msg, Utils::NormalMessageFormat);
m_applicationLauncher.start(r);
@@ -103,11 +100,6 @@ LocalApplicationRunControl::StopResult LocalApplicationRunControl::stop()
return StoppedSynchronously;
}
-bool LocalApplicationRunControl::isRunning() const
-{
- return m_running;
-}
-
void LocalApplicationRunControl::processStarted()
{
// Console processes only know their pid after being started
@@ -116,8 +108,6 @@ void LocalApplicationRunControl::processStarted()
void LocalApplicationRunControl::processExited(int exitCode, QProcess::ExitStatus status)
{
- m_running = false;
- setApplicationProcessHandle(ProcessHandle());
QString msg;
QString exe = runnable().as<StandardRunnable>().executable;
if (status == QProcess::CrashExit)
@@ -125,7 +115,7 @@ void LocalApplicationRunControl::processExited(int exitCode, QProcess::ExitStatu
else
msg = tr("%1 exited with code %2").arg(QDir::toNativeSeparators(exe)).arg(exitCode);
appendMessage(msg + QLatin1Char('\n'), Utils::NormalMessageFormat);
- emit finished();
+ reportApplicationStop();
}
// LocalApplicationRunControlFactory
diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp
index d5e0c6e56f..443491b1af 100644
--- a/src/plugins/projectexplorer/runconfiguration.cpp
+++ b/src/plugins/projectexplorer/runconfiguration.cpp
@@ -37,6 +37,7 @@
#include <utils/algorithm.h>
#include <utils/outputformatter.h>
#include <utils/checkablemessagebox.h>
+#include <utils/qtcassert.h>
#include <coreplugin/icore.h>
#include <coreplugin/icontext.h>
@@ -534,10 +535,12 @@ public:
// A handle to the actual application process.
Utils::ProcessHandle applicationProcessHandle;
+ bool isRunning = false;
+
#ifdef Q_OS_OSX
//these two are used to bring apps in the foreground on Mac
- qint64 internalPid;
int foregroundCount;
+ qint64 internalPid;
#endif
};
@@ -662,7 +665,7 @@ void RunControl::setApplicationProcessHandle(const ProcessHandle &handle)
{
if (d->applicationProcessHandle != handle) {
d->applicationProcessHandle = handle;
- emit applicationProcessHandleChanged();
+ emit applicationProcessHandleChanged(QPrivateSignal());
}
}
@@ -685,6 +688,11 @@ bool RunControl::promptToStop(bool *optionalPrompt) const
optionalPrompt);
}
+bool RunControl::isRunning() const
+{
+ return d->isRunning;
+}
+
/*!
Prompts to terminate the application with the \gui {Do not ask again}
checkbox.
@@ -732,6 +740,20 @@ void RunControl::bringApplicationToForeground(qint64 pid)
#endif
}
+void RunControl::reportApplicationStart()
+{
+ d->isRunning = true;
+ emit started(QPrivateSignal());
+}
+
+void RunControl::reportApplicationStop()
+{
+ d->isRunning = false;
+ QTC_CHECK(d->applicationProcessHandle.isValid());
+ setApplicationProcessHandle(Utils::ProcessHandle());
+ emit finished(QPrivateSignal());
+}
+
void RunControl::bringApplicationToForegroundInternal()
{
#ifdef Q_OS_OSX
diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h
index 15d7c3abbf..f50ff7c10b 100644
--- a/src/plugins/projectexplorer/runconfiguration.h
+++ b/src/plugins/projectexplorer/runconfiguration.h
@@ -361,12 +361,14 @@ public:
virtual bool promptToStop(bool *optionalPrompt = nullptr) const;
virtual StopResult stop() = 0;
- virtual bool isRunning() const = 0;
virtual bool supportsReRunning() const { return true; }
+
virtual QString displayName() const;
void setDisplayName(const QString &displayName);
+ bool isRunning() const;
+
void setIcon(const Utils::Icon &icon);
Utils::Icon icon() const;
@@ -396,11 +398,14 @@ public slots:
signals:
void appendMessageRequested(ProjectExplorer::RunControl *runControl,
const QString &msg, Utils::OutputFormat format);
- void started();
- void finished();
- void applicationProcessHandleChanged();
+ void started(QPrivateSignal); // Use reportApplicationStart!
+ void finished(QPrivateSignal); // Use reportApplicationStop!
+ void applicationProcessHandleChanged(QPrivateSignal); // Use setApplicationProcessHandle
protected:
+ void reportApplicationStart(); // Call this when the application starts to run
+ void reportApplicationStop(); // Call this when the application has stopped for any reason
+
bool showPromptToStopDialog(const QString &title, const QString &text,
const QString &stopButtonText = QString(),
const QString &cancelButtonText = QString(),
diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp
index 6324769947..f3f4ae1858 100644
--- a/src/plugins/pythoneditor/pythoneditorplugin.cpp
+++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp
@@ -225,7 +225,6 @@ public:
void start() override;
StopResult stop() override;
- bool isRunning() const override { return m_running; }
private:
void processStarted();
@@ -238,7 +237,6 @@ private:
QString m_commandLineArguments;
Utils::Environment m_environment;
ApplicationLauncher::Mode m_runMode;
- bool m_running;
};
////////////////////////////////////////////////////////////////
@@ -756,7 +754,7 @@ RunControl *PythonRunControlFactory::create(RunConfiguration *runConfiguration,
// PythonRunControl
PythonRunControl::PythonRunControl(PythonRunConfiguration *rc, Core::Id mode)
- : RunControl(rc, mode), m_running(false)
+ : RunControl(rc, mode)
{
setIcon(Utils::Icons::RUN_SMALL_TOOLBAR);
@@ -778,16 +776,15 @@ PythonRunControl::PythonRunControl(PythonRunConfiguration *rc, Core::Id mode)
void PythonRunControl::start()
{
- emit started();
+ reportApplicationStart();
if (m_interpreter.isEmpty()) {
appendMessage(tr("No Python interpreter specified.") + '\n', Utils::ErrorMessageFormat);
- emit finished();
+ reportApplicationStop();
} else if (!QFileInfo::exists(m_interpreter)) {
appendMessage(tr("Python interpreter %1 does not exist.").arg(QDir::toNativeSeparators(m_interpreter)) + '\n',
Utils::ErrorMessageFormat);
- emit finished();
+ reportApplicationStop();
} else {
- m_running = true;
QString msg = tr("Starting %1...").arg(QDir::toNativeSeparators(m_interpreter)) + '\n';
appendMessage(msg, Utils::NormalMessageFormat);
@@ -822,8 +819,6 @@ void PythonRunControl::processStarted()
void PythonRunControl::processExited(int exitCode, QProcess::ExitStatus status)
{
- m_running = false;
- setApplicationProcessHandle(ProcessHandle());
QString msg;
if (status == QProcess::CrashExit) {
msg = tr("%1 crashed")
@@ -833,7 +828,7 @@ void PythonRunControl::processExited(int exitCode, QProcess::ExitStatus status)
.arg(QDir::toNativeSeparators(m_interpreter)).arg(exitCode);
}
appendMessage(msg + '\n', Utils::NormalMessageFormat);
- emit finished();
+ reportApplicationStop();
}
void PythonRunConfigurationWidget::setInterpreter(const QString &interpreter)
diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp
index 224e5652cf..f0a64d2a5a 100644
--- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp
@@ -70,7 +70,6 @@ public:
Internal::QmlProfilerTool *m_tool = 0;
QmlProfilerStateManager *m_profilerState = 0;
QTimer m_noDebugOutputTimer;
- bool m_running = false;
};
//
@@ -96,17 +95,18 @@ QmlProfilerRunControl::QmlProfilerRunControl(RunConfiguration *runConfiguration,
QmlProfilerRunControl::~QmlProfilerRunControl()
{
- if (d->m_running && d->m_profilerState)
+ if (isRunning() && d->m_profilerState)
stop();
delete d;
}
void QmlProfilerRunControl::start()
{
+ reportApplicationStart();
d->m_tool->finalizeRunControl(this);
- QTC_ASSERT(d->m_profilerState, finished(); return);
+ QTC_ASSERT(d->m_profilerState, reportApplicationStop(); return);
- QTC_ASSERT(connection().is<AnalyzerConnection>(), finished(); return);
+ QTC_ASSERT(connection().is<AnalyzerConnection>(), reportApplicationStop(); return);
auto conn = connection().as<AnalyzerConnection>();
if (conn.analyzerPort.isValid())
@@ -115,13 +115,11 @@ void QmlProfilerRunControl::start()
d->m_noDebugOutputTimer.start();
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning);
- d->m_running = true;
emit starting();
}
RunControl::StopResult QmlProfilerRunControl::stop()
{
- d->m_running = false;
QTC_ASSERT(d->m_profilerState, return RunControl::StoppedSynchronously);
switch (d->m_profilerState->currentState()) {
@@ -147,11 +145,6 @@ RunControl::StopResult QmlProfilerRunControl::stop()
return RunControl::StoppedSynchronously;
}
-bool QmlProfilerRunControl::isRunning() const
-{
- return d->m_running;
-}
-
void QmlProfilerRunControl::notifyRemoteFinished()
{
QTC_ASSERT(d->m_profilerState, return);
@@ -159,8 +152,7 @@ void QmlProfilerRunControl::notifyRemoteFinished()
switch (d->m_profilerState->currentState()) {
case QmlProfilerStateManager::AppRunning:
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
- d->m_running = false;
- emit finished();
+ reportApplicationStop();
break;
case QmlProfilerStateManager::Idle:
break;
@@ -189,8 +181,7 @@ void QmlProfilerRunControl::cancelProcess()
return;
}
}
- d->m_running = false;
- emit finished();
+ reportApplicationStop();
}
void QmlProfilerRunControl::notifyRemoteSetupFailed(const QString &errorMessage)
@@ -213,8 +204,7 @@ void QmlProfilerRunControl::notifyRemoteSetupFailed(const QString &errorMessage)
// KILL
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
d->m_noDebugOutputTimer.stop();
- d->m_running = false;
- emit finished();
+ reportApplicationStop();
}
void QmlProfilerRunControl::wrongSetupMessageBoxFinished(int button)
@@ -256,8 +246,7 @@ void QmlProfilerRunControl::profilerStateChanged()
{
switch (d->m_profilerState->currentState()) {
case QmlProfilerStateManager::Idle:
- d->m_running = false;
- emit finished();
+ reportApplicationStop();
d->m_noDebugOutputTimer.stop();
break;
default:
diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h
index 49716c05a4..5c7c770755 100644
--- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h
+++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h
@@ -49,7 +49,6 @@ public:
void notifyRemoteSetupFailed(const QString &errorMessage) override;
void start() override;
StopResult stop() override;
- bool isRunning() const override;
void cancelProcess();
void notifyRemoteFinished() override;
bool supportsReRunning() const override { return false; }
diff --git a/src/plugins/remotelinux/remotelinuxruncontrol.cpp b/src/plugins/remotelinux/remotelinuxruncontrol.cpp
index 7e9c495180..5bbd63c18d 100644
--- a/src/plugins/remotelinux/remotelinuxruncontrol.cpp
+++ b/src/plugins/remotelinux/remotelinuxruncontrol.cpp
@@ -36,7 +36,6 @@ namespace RemoteLinux {
class RemoteLinuxRunControl::RemoteLinuxRunControlPrivate
{
public:
- bool running;
DeviceApplicationRunner runner;
};
@@ -45,8 +44,6 @@ RemoteLinuxRunControl::RemoteLinuxRunControl(RunConfiguration *rc)
{
setIcon(Utils::Icons::RUN_SMALL_TOOLBAR);
setRunnable(rc->runnable());
-
- d->running = false;
}
RemoteLinuxRunControl::~RemoteLinuxRunControl()
@@ -56,8 +53,7 @@ RemoteLinuxRunControl::~RemoteLinuxRunControl()
void RemoteLinuxRunControl::start()
{
- d->running = true;
- emit started();
+ reportApplicationStart();
d->runner.disconnect(this);
connect(&d->runner, &DeviceApplicationRunner::reportError,
this, &RemoteLinuxRunControl::handleErrorMessage);
@@ -103,16 +99,10 @@ void RemoteLinuxRunControl::handleProgressReport(const QString &progressString)
appendMessage(progressString + QLatin1Char('\n'), Utils::NormalMessageFormat);
}
-bool RemoteLinuxRunControl::isRunning() const
-{
- return d->running;
-}
-
void RemoteLinuxRunControl::setFinished()
{
d->runner.disconnect(this);
- d->running = false;
- emit finished();
+ reportApplicationStop();
}
} // namespace RemoteLinux
diff --git a/src/plugins/remotelinux/remotelinuxruncontrol.h b/src/plugins/remotelinux/remotelinuxruncontrol.h
index fd98845627..8582d3013b 100644
--- a/src/plugins/remotelinux/remotelinuxruncontrol.h
+++ b/src/plugins/remotelinux/remotelinuxruncontrol.h
@@ -40,7 +40,6 @@ public:
virtual void start() override;
virtual StopResult stop() override;
- virtual bool isRunning() const override;
private:
void handleErrorMessage(const QString &error);
diff --git a/src/plugins/valgrind/valgrindengine.cpp b/src/plugins/valgrind/valgrindengine.cpp
index 6e08ae66dc..fb41439943 100644
--- a/src/plugins/valgrind/valgrindengine.cpp
+++ b/src/plugins/valgrind/valgrindengine.cpp
@@ -70,6 +70,7 @@ ValgrindRunControl::ValgrindRunControl(RunConfiguration *runConfiguration, Core:
void ValgrindRunControl::start()
{
+ reportApplicationStart();
emit starting();
FutureProgress *fp = ProgressManager::addTimedTask(m_progress, progressTitle(), "valgrind", 100);
fp->setKeepOnFinish(FutureProgress::HideOnFinish);
@@ -101,12 +102,9 @@ void ValgrindRunControl::start()
if (!run->start()) {
m_progress.cancel();
- emit finished();
+ reportApplicationStop();
return;
}
-
- m_isRunning = true;
- emit started();
}
RunControl::StopResult ValgrindRunControl::stop()
@@ -116,11 +114,6 @@ RunControl::StopResult ValgrindRunControl::stop()
return AsynchronousStop;
}
-bool ValgrindRunControl::isRunning() const
-{
- return m_isRunning;
-}
-
QString ValgrindRunControl::executable() const
{
return runnable().as<StandardRunnable>().executable;
@@ -161,10 +154,8 @@ void ValgrindRunControl::handleProgressFinished()
void ValgrindRunControl::runnerFinished()
{
- m_isRunning = false;
-
appendMessage(tr("Analyzing finished.") + QLatin1Char('\n'), NormalMessageFormat);
- emit finished();
+ reportApplicationStop();
m_progress.reportFinished();
diff --git a/src/plugins/valgrind/valgrindengine.h b/src/plugins/valgrind/valgrindengine.h
index d5b0e2ef32..cd3fbfe75d 100644
--- a/src/plugins/valgrind/valgrindengine.h
+++ b/src/plugins/valgrind/valgrindengine.h
@@ -47,7 +47,6 @@ public:
void start() override;
StopResult stop() override;
- bool isRunning() const override;
bool supportsReRunning() const override { return false; }
QString executable() const;
@@ -71,7 +70,6 @@ private:
QStringList genericToolArguments() const;
private:
- bool m_isRunning = false;
bool m_isStopping = false;
};
diff --git a/src/plugins/winrt/winrtruncontrol.cpp b/src/plugins/winrt/winrtruncontrol.cpp
index 2644b92152..c211a46304 100644
--- a/src/plugins/winrt/winrtruncontrol.cpp
+++ b/src/plugins/winrt/winrtruncontrol.cpp
@@ -63,6 +63,8 @@ void WinRtRunControl::start()
return;
if (!startWinRtRunner())
m_state = StoppedState;
+ else
+ reportApplicationStart();
}
RunControl::StopResult WinRtRunControl::stop()
@@ -74,16 +76,10 @@ RunControl::StopResult WinRtRunControl::stop()
return AsynchronousStop;
}
-bool WinRtRunControl::isRunning() const
-{
- return m_state == StartedState;
-}
-
void WinRtRunControl::onProcessStarted()
{
QTC_CHECK(m_state == StartingState);
m_state = StartedState;
- emit started();
}
void WinRtRunControl::onProcessFinished()
@@ -99,7 +95,7 @@ void WinRtRunControl::onProcessError()
m_runner->deleteLater();
m_runner = 0;
m_state = StoppedState;
- emit finished();
+ reportApplicationStop();
}
bool WinRtRunControl::startWinRtRunner()
diff --git a/src/plugins/winrt/winrtruncontrol.h b/src/plugins/winrt/winrtruncontrol.h
index 902ea289a2..e30f6424a0 100644
--- a/src/plugins/winrt/winrtruncontrol.h
+++ b/src/plugins/winrt/winrtruncontrol.h
@@ -52,7 +52,6 @@ public:
void start() override;
StopResult stop() override;
- bool isRunning() const override;
private:
enum State { StartingState, StartedState, StoppedState };