diff --git a/src/plugins/android/androidruncontrol.cpp b/src/plugins/android/androidruncontrol.cpp index b7d8c92004f..7c5d815a168 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 472856f7d78..5dc9fffb6b5 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 544832013a6..019b0632b54 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 ce974bac37f..9776de88d2e 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 426b36df042..49e85e98405 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 9a98dbdd2a3..f2c61e21054 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 cdfa5cf9ac2..16997045327 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 082d94669f0..b60f73d4527 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 baff9ad6f3a..b0c4da00226 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()) { 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 530361e2ef8..0eba08e8cea 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 22b021ed0af..44826940ea5 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(), return); auto r = runnable().as(); - 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().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 d5e0c6e56f8..443491b1af3 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -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 15d7c3abbfe..f50ff7c10b0 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 63247699470..f3f4ae18585 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 224e5652cf7..f0a64d2a5a2 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(), finished(); return); + QTC_ASSERT(connection().is(), reportApplicationStop(); return); auto conn = connection().as(); 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 49716c05a44..5c7c770755b 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 7e9c4951800..5bbd63c18d0 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 fd988456276..8582d3013b4 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 6e08ae66dc4..fb41439943d 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().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 d5b0e2ef329..cd3fbfe75da 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 2644b92152d..c211a463043 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 902ea289a2e..e30f6424a09 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 };