forked from qt-creator/qt-creator
Uniform ApplicationLauncher API: get rid of finished()
Use existing processExited() signal instead. Change-Id: I1eecaa05fa8b3a97d8585fca4ca89e8e1acecec3 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -81,7 +81,7 @@ public:
|
|||||||
&DeviceApplicationObserver::handleAppendMessage);
|
&DeviceApplicationObserver::handleAppendMessage);
|
||||||
connect(&m_appRunner, &ApplicationLauncher::error, this,
|
connect(&m_appRunner, &ApplicationLauncher::error, this,
|
||||||
[this] { m_error = m_appRunner.errorString(); });
|
[this] { m_error = m_appRunner.errorString(); });
|
||||||
connect(&m_appRunner, &ApplicationLauncher::finished, this,
|
connect(&m_appRunner, &ApplicationLauncher::processExited, this,
|
||||||
&DeviceApplicationObserver::handleFinished);
|
&DeviceApplicationObserver::handleFinished);
|
||||||
|
|
||||||
QTC_ASSERT(device, return);
|
QTC_ASSERT(device, return);
|
||||||
@@ -103,14 +103,14 @@ private:
|
|||||||
m_stderr += data;
|
m_stderr += data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleFinished(bool success)
|
void handleFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||||
{
|
{
|
||||||
if (success && (m_stdout.contains("fail") || m_stdout.contains("error")
|
Q_UNUSED(exitCode)
|
||||||
|| m_stdout.contains("not found"))) {
|
|
||||||
// FIXME: Needed in a post-adb world?
|
// FIXME: Needed in a post-adb world?
|
||||||
success = false; // adb does not forward exit codes and all stderr goes to stdout.
|
// adb does not forward exit codes and all stderr goes to stdout.
|
||||||
}
|
const bool failure = exitStatus == QProcess::CrashExit || m_stdout.contains("fail")
|
||||||
if (!success) {
|
|| m_stdout.contains("error") || m_stdout.contains("not found");
|
||||||
|
if (failure) {
|
||||||
QString errorString;
|
QString errorString;
|
||||||
if (!m_error.isEmpty()) {
|
if (!m_error.isEmpty()) {
|
||||||
errorString = QdbDevice::tr("Command failed on device \"%1\": %2")
|
errorString = QdbDevice::tr("Command failed on device \"%1\": %2")
|
||||||
|
@@ -57,7 +57,7 @@ public:
|
|||||||
|
|
||||||
connect(&m_launcher, &ApplicationLauncher::processStarted,
|
connect(&m_launcher, &ApplicationLauncher::processStarted,
|
||||||
this, &RunWorker::reportStarted);
|
this, &RunWorker::reportStarted);
|
||||||
connect(&m_launcher, &ApplicationLauncher::finished,
|
connect(&m_launcher, &ApplicationLauncher::processExited,
|
||||||
this, &RunWorker::reportStopped);
|
this, &RunWorker::reportStopped);
|
||||||
connect(&m_launcher, &ApplicationLauncher::appendMessage,
|
connect(&m_launcher, &ApplicationLauncher::appendMessage,
|
||||||
this, &RunWorker::appendMessage);
|
this, &RunWorker::appendMessage);
|
||||||
|
@@ -57,10 +57,11 @@ QdbStopApplicationService::~QdbStopApplicationService()
|
|||||||
delete d;
|
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.");
|
const auto failureMessage = tr("Could not check and possibly stop running application.");
|
||||||
if (!success) {
|
if (exitStatus == QProcess::CrashExit) {
|
||||||
emit errorMessage(failureMessage);
|
emit errorMessage(failureMessage);
|
||||||
stopDeployment();
|
stopDeployment();
|
||||||
return;
|
return;
|
||||||
@@ -90,7 +91,7 @@ void QdbStopApplicationService::doDeploy()
|
|||||||
{
|
{
|
||||||
connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::error,
|
connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::error,
|
||||||
this, [this] { emit stdErrData(d->applicationLauncher.errorString()); });
|
this, [this] { emit stdErrData(d->applicationLauncher.errorString()); });
|
||||||
connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::finished,
|
connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::processExited,
|
||||||
this, &QdbStopApplicationService::handleProcessFinished);
|
this, &QdbStopApplicationService::handleProcessFinished);
|
||||||
connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::appendMessage,
|
connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::appendMessage,
|
||||||
this, &QdbStopApplicationService::handleAppendMessage);
|
this, &QdbStopApplicationService::handleAppendMessage);
|
||||||
|
@@ -28,6 +28,8 @@
|
|||||||
#include <remotelinux/abstractremotelinuxdeployservice.h>
|
#include <remotelinux/abstractremotelinuxdeployservice.h>
|
||||||
#include <utils/outputformat.h>
|
#include <utils/outputformat.h>
|
||||||
|
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
namespace Qdb {
|
namespace Qdb {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -41,7 +43,7 @@ public:
|
|||||||
~QdbStopApplicationService();
|
~QdbStopApplicationService();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleProcessFinished(bool success);
|
void handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||||
void handleAppendMessage(const QString &message, Utils::OutputFormat format);
|
void handleAppendMessage(const QString &message, Utils::OutputFormat format);
|
||||||
|
|
||||||
bool isDeploymentNecessary() const final { return true; }
|
bool isDeploymentNecessary() const final { return true; }
|
||||||
|
@@ -119,9 +119,9 @@ public:
|
|||||||
DeviceProcess *m_deviceProcess = nullptr;
|
DeviceProcess *m_deviceProcess = nullptr;
|
||||||
QString m_remoteErrorString;
|
QString m_remoteErrorString;
|
||||||
QProcess::ProcessError m_remoteError = QProcess::UnknownError;
|
QProcess::ProcessError m_remoteError = QProcess::UnknownError;
|
||||||
|
QProcess::ExitStatus m_remoteExitStatus = QProcess::CrashExit;
|
||||||
State m_state = Inactive;
|
State m_state = Inactive;
|
||||||
bool m_stopRequested = false;
|
bool m_stopRequested = false;
|
||||||
bool m_success = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
@@ -213,7 +213,7 @@ void ApplicationLauncherPrivate::stop()
|
|||||||
if (m_stopRequested)
|
if (m_stopRequested)
|
||||||
return;
|
return;
|
||||||
m_stopRequested = true;
|
m_stopRequested = true;
|
||||||
m_success = false;
|
m_remoteExitStatus = QProcess::CrashExit;
|
||||||
emit q->appendMessage(ApplicationLauncher::tr("User requested stop. Shutting down..."),
|
emit q->appendMessage(ApplicationLauncher::tr("User requested stop. Shutting down..."),
|
||||||
Utils::NormalMessageFormat);
|
Utils::NormalMessageFormat);
|
||||||
switch (m_state) {
|
switch (m_state) {
|
||||||
@@ -423,7 +423,7 @@ void ApplicationLauncherPrivate::start(const Runnable &runnable, const IDevice::
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_stopRequested = false;
|
m_stopRequested = false;
|
||||||
m_success = true;
|
m_remoteExitStatus = QProcess::NormalExit;
|
||||||
|
|
||||||
m_deviceProcess = device->createProcess(this);
|
m_deviceProcess = device->createProcess(this);
|
||||||
m_deviceProcess->setRunInTerminal(m_useTerminal);
|
m_deviceProcess->setRunInTerminal(m_useTerminal);
|
||||||
@@ -455,14 +455,16 @@ void ApplicationLauncherPrivate::setFinished()
|
|||||||
if (m_state == Inactive)
|
if (m_state == Inactive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
int exitCode = 0;
|
||||||
if (m_deviceProcess) {
|
if (m_deviceProcess) {
|
||||||
|
exitCode = m_deviceProcess->exitCode();
|
||||||
m_deviceProcess->disconnect(this);
|
m_deviceProcess->disconnect(this);
|
||||||
m_deviceProcess->deleteLater();
|
m_deviceProcess->deleteLater();
|
||||||
m_deviceProcess = nullptr;
|
m_deviceProcess = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_state = Inactive;
|
m_state = Inactive;
|
||||||
emit q->finished(m_success);
|
emit q->processExited(exitCode, m_remoteExitStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationLauncherPrivate::handleApplicationFinished()
|
void ApplicationLauncherPrivate::handleApplicationFinished()
|
||||||
@@ -502,7 +504,7 @@ void ApplicationLauncherPrivate::doReportError(const QString &message, QProcess:
|
|||||||
{
|
{
|
||||||
m_remoteErrorString = message;
|
m_remoteErrorString = message;
|
||||||
m_remoteError = error;
|
m_remoteError = error;
|
||||||
m_success = false;
|
m_remoteExitStatus = QProcess::CrashExit;
|
||||||
emit q->error(error);
|
emit q->error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -71,11 +71,9 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void appendMessage(const QString &message, Utils::OutputFormat format, bool appendNewLine = true);
|
void appendMessage(const QString &message, Utils::OutputFormat format, bool appendNewLine = true);
|
||||||
void processStarted();
|
void processStarted();
|
||||||
void processExited(int exitCode, QProcess::ExitStatus);
|
void processExited(int exitCode, QProcess::ExitStatus exitStatus);
|
||||||
void error(QProcess::ProcessError error);
|
void error(QProcess::ProcessError error);
|
||||||
|
|
||||||
void finished(bool success);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Internal::ApplicationLauncherPrivate> d;
|
std::unique_ptr<Internal::ApplicationLauncherPrivate> d;
|
||||||
};
|
};
|
||||||
|
@@ -1256,12 +1256,6 @@ void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstP
|
|||||||
reportFailure(m_launcher.errorString());
|
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::processStarted, this, &RunWorker::reportStarted);
|
||||||
|
|
||||||
connect(&m_launcher, &ApplicationLauncher::processExited,
|
connect(&m_launcher, &ApplicationLauncher::processExited,
|
||||||
|
@@ -121,8 +121,6 @@ void CallgrindController::run(Option option)
|
|||||||
this, &CallgrindController::controllerProcessFinished);
|
this, &CallgrindController::controllerProcessFinished);
|
||||||
connect(m_controllerProcess, &ApplicationLauncher::error,
|
connect(m_controllerProcess, &ApplicationLauncher::error,
|
||||||
this, &CallgrindController::handleControllerProcessError);
|
this, &CallgrindController::handleControllerProcessError);
|
||||||
connect(m_controllerProcess, &ApplicationLauncher::finished,
|
|
||||||
this, &CallgrindController::controllerProcessClosed);
|
|
||||||
|
|
||||||
Runnable controller = m_valgrindRunnable;
|
Runnable controller = m_valgrindRunnable;
|
||||||
controller.command.setExecutable(FilePath::fromString(CALLGRIND_CONTROL_BINARY));
|
controller.command.setExecutable(FilePath::fromString(CALLGRIND_CONTROL_BINARY));
|
||||||
@@ -185,24 +183,6 @@ void CallgrindController::controllerProcessFinished(int rc, QProcess::ExitStatus
|
|||||||
m_lastOption = Unknown;
|
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()
|
void CallgrindController::getLocalDataFile()
|
||||||
{
|
{
|
||||||
cleanupTempFile();
|
cleanupTempFile();
|
||||||
|
@@ -78,7 +78,6 @@ private:
|
|||||||
|
|
||||||
void controllerProcessFinished(int, QProcess::ExitStatus);
|
void controllerProcessFinished(int, QProcess::ExitStatus);
|
||||||
void controllerProcessError(QProcess::ProcessError);
|
void controllerProcessError(QProcess::ProcessError);
|
||||||
void controllerProcessClosed(bool success);
|
|
||||||
|
|
||||||
ProjectExplorer::ApplicationLauncher *m_controllerProcess = nullptr;
|
ProjectExplorer::ApplicationLauncher *m_controllerProcess = nullptr;
|
||||||
ProjectExplorer::Runnable m_valgrindRunnable;
|
ProjectExplorer::Runnable m_valgrindRunnable;
|
||||||
|
@@ -48,7 +48,6 @@ public:
|
|||||||
|
|
||||||
bool run();
|
bool run();
|
||||||
|
|
||||||
void closed(bool success);
|
|
||||||
void processStarted();
|
void processStarted();
|
||||||
void localProcessStarted();
|
void localProcessStarted();
|
||||||
void remoteProcessStarted();
|
void remoteProcessStarted();
|
||||||
@@ -116,15 +115,13 @@ bool ValgrindRunner::Private::run()
|
|||||||
// -q as suggested by valgrind manual
|
// -q as suggested by valgrind manual
|
||||||
|
|
||||||
connect(&m_valgrindProcess, &ApplicationLauncher::processExited,
|
connect(&m_valgrindProcess, &ApplicationLauncher::processExited,
|
||||||
this, &ValgrindRunner::Private::closed);
|
q, &ValgrindRunner::processFinished);
|
||||||
connect(&m_valgrindProcess, &ApplicationLauncher::processStarted,
|
connect(&m_valgrindProcess, &ApplicationLauncher::processStarted,
|
||||||
this, &ValgrindRunner::Private::processStarted);
|
this, &ValgrindRunner::Private::processStarted);
|
||||||
connect(&m_valgrindProcess, &ApplicationLauncher::error,
|
connect(&m_valgrindProcess, &ApplicationLauncher::error,
|
||||||
q, &ValgrindRunner::processError);
|
q, &ValgrindRunner::processError);
|
||||||
connect(&m_valgrindProcess, &ApplicationLauncher::appendMessage,
|
connect(&m_valgrindProcess, &ApplicationLauncher::appendMessage,
|
||||||
q, &ValgrindRunner::processOutputReceived);
|
q, &ValgrindRunner::processOutputReceived);
|
||||||
connect(&m_valgrindProcess, &ApplicationLauncher::finished,
|
|
||||||
q, &ValgrindRunner::finished);
|
|
||||||
|
|
||||||
if (HostOsInfo::isMacHost())
|
if (HostOsInfo::isMacHost())
|
||||||
// May be slower to start but without it we get no filenames for symbols.
|
// 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)
|
ValgrindRunner::ValgrindRunner(QObject *parent)
|
||||||
: QObject(parent), d(new Private(this))
|
: QObject(parent), d(new Private(this))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user