diff --git a/src/plugins/boot2qt/qdbdevice.cpp b/src/plugins/boot2qt/qdbdevice.cpp index ade393f363d..045ac410b65 100644 --- a/src/plugins/boot2qt/qdbdevice.cpp +++ b/src/plugins/boot2qt/qdbdevice.cpp @@ -81,7 +81,7 @@ public: &DeviceApplicationObserver::handleAppendMessage); connect(&m_appRunner, &ApplicationLauncher::error, this, [this] { m_error = m_appRunner.errorString(); }); - connect(&m_appRunner, &ApplicationLauncher::finished, this, + connect(&m_appRunner, &ApplicationLauncher::processExited, this, &DeviceApplicationObserver::handleFinished); QTC_ASSERT(device, return); @@ -103,14 +103,14 @@ private: m_stderr += data; } - void handleFinished(bool success) + void handleFinished(int exitCode, QProcess::ExitStatus exitStatus) { - if (success && (m_stdout.contains("fail") || m_stdout.contains("error") - || m_stdout.contains("not found"))) { - // FIXME: Needed in a post-adb world? - success = false; // adb does not forward exit codes and all stderr goes to stdout. - } - if (!success) { + Q_UNUSED(exitCode) + // FIXME: Needed in a post-adb world? + // adb does not forward exit codes and all stderr goes to stdout. + const bool failure = exitStatus == QProcess::CrashExit || m_stdout.contains("fail") + || m_stdout.contains("error") || m_stdout.contains("not found"); + if (failure) { QString errorString; if (!m_error.isEmpty()) { errorString = QdbDevice::tr("Command failed on device \"%1\": %2") diff --git a/src/plugins/boot2qt/qdbdevicedebugsupport.cpp b/src/plugins/boot2qt/qdbdevicedebugsupport.cpp index 184346a40c8..153c21be453 100644 --- a/src/plugins/boot2qt/qdbdevicedebugsupport.cpp +++ b/src/plugins/boot2qt/qdbdevicedebugsupport.cpp @@ -57,7 +57,7 @@ public: connect(&m_launcher, &ApplicationLauncher::processStarted, this, &RunWorker::reportStarted); - connect(&m_launcher, &ApplicationLauncher::finished, + connect(&m_launcher, &ApplicationLauncher::processExited, this, &RunWorker::reportStopped); connect(&m_launcher, &ApplicationLauncher::appendMessage, this, &RunWorker::appendMessage); diff --git a/src/plugins/boot2qt/qdbstopapplicationservice.cpp b/src/plugins/boot2qt/qdbstopapplicationservice.cpp index 98f96616c1e..018e6bdbb70 100644 --- a/src/plugins/boot2qt/qdbstopapplicationservice.cpp +++ b/src/plugins/boot2qt/qdbstopapplicationservice.cpp @@ -57,10 +57,11 @@ QdbStopApplicationService::~QdbStopApplicationService() delete d; } -void QdbStopApplicationService::handleProcessFinished(bool success) +void QdbStopApplicationService::handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) { + Q_UNUSED(exitCode) const auto failureMessage = tr("Could not check and possibly stop running application."); - if (!success) { + if (exitStatus == QProcess::CrashExit) { emit errorMessage(failureMessage); stopDeployment(); return; @@ -90,7 +91,7 @@ void QdbStopApplicationService::doDeploy() { connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::error, this, [this] { emit stdErrData(d->applicationLauncher.errorString()); }); - connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::finished, + connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::processExited, this, &QdbStopApplicationService::handleProcessFinished); connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::appendMessage, this, &QdbStopApplicationService::handleAppendMessage); diff --git a/src/plugins/boot2qt/qdbstopapplicationservice.h b/src/plugins/boot2qt/qdbstopapplicationservice.h index 406f8e50f9d..1b59073e37c 100644 --- a/src/plugins/boot2qt/qdbstopapplicationservice.h +++ b/src/plugins/boot2qt/qdbstopapplicationservice.h @@ -28,6 +28,8 @@ #include #include +#include + namespace Qdb { namespace Internal { @@ -41,7 +43,7 @@ public: ~QdbStopApplicationService(); private: - void handleProcessFinished(bool success); + void handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); void handleAppendMessage(const QString &message, Utils::OutputFormat format); bool isDeploymentNecessary() const final { return true; } diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp index 1c77b7616cc..4e9ae25d753 100644 --- a/src/plugins/projectexplorer/applicationlauncher.cpp +++ b/src/plugins/projectexplorer/applicationlauncher.cpp @@ -119,9 +119,9 @@ public: DeviceProcess *m_deviceProcess = nullptr; QString m_remoteErrorString; QProcess::ProcessError m_remoteError = QProcess::UnknownError; + QProcess::ExitStatus m_remoteExitStatus = QProcess::CrashExit; State m_state = Inactive; bool m_stopRequested = false; - bool m_success = false; }; } // Internal @@ -213,7 +213,7 @@ void ApplicationLauncherPrivate::stop() if (m_stopRequested) return; m_stopRequested = true; - m_success = false; + m_remoteExitStatus = QProcess::CrashExit; emit q->appendMessage(ApplicationLauncher::tr("User requested stop. Shutting down..."), Utils::NormalMessageFormat); switch (m_state) { @@ -423,7 +423,7 @@ void ApplicationLauncherPrivate::start(const Runnable &runnable, const IDevice:: } m_stopRequested = false; - m_success = true; + m_remoteExitStatus = QProcess::NormalExit; m_deviceProcess = device->createProcess(this); m_deviceProcess->setRunInTerminal(m_useTerminal); @@ -455,14 +455,16 @@ void ApplicationLauncherPrivate::setFinished() if (m_state == Inactive) return; + int exitCode = 0; if (m_deviceProcess) { + exitCode = m_deviceProcess->exitCode(); m_deviceProcess->disconnect(this); m_deviceProcess->deleteLater(); m_deviceProcess = nullptr; } m_state = Inactive; - emit q->finished(m_success); + emit q->processExited(exitCode, m_remoteExitStatus); } void ApplicationLauncherPrivate::handleApplicationFinished() @@ -502,7 +504,7 @@ void ApplicationLauncherPrivate::doReportError(const QString &message, QProcess: { m_remoteErrorString = message; m_remoteError = error; - m_success = false; + m_remoteExitStatus = QProcess::CrashExit; emit q->error(error); } diff --git a/src/plugins/projectexplorer/applicationlauncher.h b/src/plugins/projectexplorer/applicationlauncher.h index 07fa19f8ace..1dcefb6cf3f 100644 --- a/src/plugins/projectexplorer/applicationlauncher.h +++ b/src/plugins/projectexplorer/applicationlauncher.h @@ -71,11 +71,9 @@ public: signals: void appendMessage(const QString &message, Utils::OutputFormat format, bool appendNewLine = true); void processStarted(); - void processExited(int exitCode, QProcess::ExitStatus); + void processExited(int exitCode, QProcess::ExitStatus exitStatus); void error(QProcess::ProcessError error); - void finished(bool success); - private: std::unique_ptr d; }; diff --git a/src/plugins/projectexplorer/runcontrol.cpp b/src/plugins/projectexplorer/runcontrol.cpp index 506cd5bce3f..e63099b172c 100644 --- a/src/plugins/projectexplorer/runcontrol.cpp +++ b/src/plugins/projectexplorer/runcontrol.cpp @@ -1256,12 +1256,6 @@ void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstP reportFailure(m_launcher.errorString()); }); - connect(&m_launcher, &ApplicationLauncher::finished, - this, [this] { - m_launcher.disconnect(this); - reportStopped(); - }); - connect(&m_launcher, &ApplicationLauncher::processStarted, this, &RunWorker::reportStarted); connect(&m_launcher, &ApplicationLauncher::processExited, diff --git a/src/plugins/valgrind/callgrind/callgrindcontroller.cpp b/src/plugins/valgrind/callgrind/callgrindcontroller.cpp index 4e570b2b05e..83f98cc71bb 100644 --- a/src/plugins/valgrind/callgrind/callgrindcontroller.cpp +++ b/src/plugins/valgrind/callgrind/callgrindcontroller.cpp @@ -121,8 +121,6 @@ void CallgrindController::run(Option option) this, &CallgrindController::controllerProcessFinished); connect(m_controllerProcess, &ApplicationLauncher::error, this, &CallgrindController::handleControllerProcessError); - connect(m_controllerProcess, &ApplicationLauncher::finished, - this, &CallgrindController::controllerProcessClosed); Runnable controller = m_valgrindRunnable; controller.command.setExecutable(FilePath::fromString(CALLGRIND_CONTROL_BINARY)); @@ -185,24 +183,6 @@ void CallgrindController::controllerProcessFinished(int rc, QProcess::ExitStatus m_lastOption = Unknown; } -void CallgrindController::controllerProcessClosed(bool success) -{ - Q_UNUSED(success) - // QTC_ASSERT(m_remote.m_process, return); - -// m_remote.m_errorString = m_remote.m_process->errorString(); -// if (status == QSsh::SshRemoteProcess::FailedToStart) { -// m_remote.m_error = QProcess::FailedToStart; -// emit ValgrindProcessX::error(QProcess::FailedToStart); -// } else if (status == QSsh::SshRemoteProcess::NormalExit) { -// emit finished(m_remote.m_process->exitCode(), QProcess::NormalExit); -// } else if (status == QSsh::SshRemoteProcess::CrashExit) { -// m_remote.m_error = QProcess::Crashed; -// emit finished(m_remote.m_process->exitCode(), QProcess::CrashExit); -// } - controllerProcessFinished(0, QProcess::NormalExit); -} - void CallgrindController::getLocalDataFile() { cleanupTempFile(); diff --git a/src/plugins/valgrind/callgrind/callgrindcontroller.h b/src/plugins/valgrind/callgrind/callgrindcontroller.h index 30e2b6c0f0a..def88ffda23 100644 --- a/src/plugins/valgrind/callgrind/callgrindcontroller.h +++ b/src/plugins/valgrind/callgrind/callgrindcontroller.h @@ -78,7 +78,6 @@ private: void controllerProcessFinished(int, QProcess::ExitStatus); void controllerProcessError(QProcess::ProcessError); - void controllerProcessClosed(bool success); ProjectExplorer::ApplicationLauncher *m_controllerProcess = nullptr; ProjectExplorer::Runnable m_valgrindRunnable; diff --git a/src/plugins/valgrind/valgrindrunner.cpp b/src/plugins/valgrind/valgrindrunner.cpp index d29a2fd917a..95cfcc0faf5 100644 --- a/src/plugins/valgrind/valgrindrunner.cpp +++ b/src/plugins/valgrind/valgrindrunner.cpp @@ -48,7 +48,6 @@ public: bool run(); - void closed(bool success); void processStarted(); void localProcessStarted(); void remoteProcessStarted(); @@ -116,15 +115,13 @@ bool ValgrindRunner::Private::run() // -q as suggested by valgrind manual connect(&m_valgrindProcess, &ApplicationLauncher::processExited, - this, &ValgrindRunner::Private::closed); + q, &ValgrindRunner::processFinished); connect(&m_valgrindProcess, &ApplicationLauncher::processStarted, this, &ValgrindRunner::Private::processStarted); connect(&m_valgrindProcess, &ApplicationLauncher::error, q, &ValgrindRunner::processError); connect(&m_valgrindProcess, &ApplicationLauncher::appendMessage, q, &ValgrindRunner::processOutputReceived); - connect(&m_valgrindProcess, &ApplicationLauncher::finished, - q, &ValgrindRunner::finished); if (HostOsInfo::isMacHost()) // May be slower to start but without it we get no filenames for symbols. @@ -218,25 +215,6 @@ void ValgrindRunner::Private::findPidOutputReceived(const QString &out, Utils::O } } -void ValgrindRunner::Private::closed(bool success) -{ - Q_UNUSED(success) -// QTC_ASSERT(m_remote.m_process, return); - -// m_remote.m_errorString = m_remote.m_process->errorString(); -// if (status == QSsh::SshRemoteProcess::FailedToStart) { -// m_remote.m_error = QProcess::FailedToStart; -// q->processError(QProcess::FailedToStart); -// } else if (status == QSsh::SshRemoteProcess::NormalExit) { -// q->processFinished(m_remote.m_process->exitCode(), QProcess::NormalExit); -// } else if (status == QSsh::SshRemoteProcess::CrashExit) { -// m_remote.m_error = QProcess::Crashed; -// q->processFinished(m_remote.m_process->exitCode(), QProcess::CrashExit); -// } - q->processFinished(0, QProcess::NormalExit); -} - - ValgrindRunner::ValgrindRunner(QObject *parent) : QObject(parent), d(new Private(this)) {