aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/localapplicationruncontrol.cpp
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 /src/plugins/projectexplorer/localapplicationruncontrol.cpp
parent329db5f4cc1fced14aeccbd2f8f580ec8c2d26a3 (diff)
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>
Diffstat (limited to 'src/plugins/projectexplorer/localapplicationruncontrol.cpp')
-rw-r--r--src/plugins/projectexplorer/localapplicationruncontrol.cpp18
1 files changed, 4 insertions, 14 deletions
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