forked from qt-creator/qt-creator
Qdb: Replace ApplicationLauncher in QdbStopApplicationStep
Change-Id: I0120a96e4289a4b12e31d805d09fca9413624c12 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "qdbconstants.h"
|
||||
|
||||
#include <projectexplorer/applicationlauncher.h>
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/runcontrol.h>
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
#include <remotelinux/abstractremotelinuxdeploystep.h>
|
||||
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
@@ -52,8 +54,7 @@ public:
|
||||
~QdbStopApplicationService() { cleanup(); }
|
||||
|
||||
private:
|
||||
void handleProcessFinished();
|
||||
void handleAppendMessage(const QString &message, OutputFormat format);
|
||||
void handleProcessDone();
|
||||
|
||||
bool isDeploymentNecessary() const final { return true; }
|
||||
|
||||
@@ -62,19 +63,25 @@ private:
|
||||
|
||||
void cleanup();
|
||||
|
||||
ApplicationLauncher m_applicationLauncher;
|
||||
QtcProcess m_process;
|
||||
QString m_errorOutput;
|
||||
};
|
||||
|
||||
void QdbStopApplicationService::handleProcessFinished()
|
||||
void QdbStopApplicationService::handleProcessDone()
|
||||
{
|
||||
const QString failureMessage = tr("Could not check and possibly stop running application.");
|
||||
if (m_applicationLauncher.exitStatus() == QProcess::CrashExit) {
|
||||
|
||||
if (m_process.exitStatus() == QProcess::CrashExit) {
|
||||
emit errorMessage(failureMessage);
|
||||
stopDeployment();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_process.result() != ProcessResult::FinishedWithSuccess) {
|
||||
emit stdErrData(m_process.errorString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_errorOutput.contains("Could not connect: Connection refused")) {
|
||||
emit progressMessage(tr("Checked that there is no running application."));
|
||||
} else if (!m_errorOutput.isEmpty()) {
|
||||
@@ -87,30 +94,24 @@ void QdbStopApplicationService::handleProcessFinished()
|
||||
stopDeployment();
|
||||
}
|
||||
|
||||
void QdbStopApplicationService::handleAppendMessage(const QString &message, OutputFormat format)
|
||||
{
|
||||
if (format == StdErrFormat)
|
||||
m_errorOutput.append(message);
|
||||
else
|
||||
emit stdOutData(message);
|
||||
}
|
||||
|
||||
void QdbStopApplicationService::doDeploy()
|
||||
{
|
||||
connect(&m_applicationLauncher, &ApplicationLauncher::errorOccurred,
|
||||
this, [this] { emit stdErrData(m_applicationLauncher.errorString()); });
|
||||
connect(&m_applicationLauncher, &ApplicationLauncher::finished,
|
||||
this, &QdbStopApplicationService::handleProcessFinished);
|
||||
connect(&m_applicationLauncher, &ApplicationLauncher::appendMessage,
|
||||
this, &QdbStopApplicationService::handleAppendMessage);
|
||||
auto device = DeviceKitAspect::device(target()->kit());
|
||||
QTC_ASSERT(device, return);
|
||||
|
||||
Runnable runnable;
|
||||
runnable.command = {Constants::AppcontrollerFilepath, {"--stop"}};
|
||||
runnable.workingDirectory = "/usr/bin";
|
||||
runnable.device = DeviceKitAspect::device(target()->kit());
|
||||
connect(&m_process, &QtcProcess::done,
|
||||
this, &QdbStopApplicationService::handleProcessDone);
|
||||
|
||||
m_applicationLauncher.setRunnable(runnable);
|
||||
m_applicationLauncher.start();
|
||||
connect(&m_process, &QtcProcess::readyReadStandardError, this, [this] {
|
||||
m_errorOutput.append(QString::fromUtf8(m_process.readAllStandardError()));
|
||||
});
|
||||
connect(&m_process, &QtcProcess::readyReadStandardOutput, this, [this] {
|
||||
emit stdOutData(QString::fromUtf8(m_process.readAllStandardOutput()));
|
||||
});
|
||||
|
||||
m_process.setCommand({device->mapToGlobalPath(Constants::AppcontrollerFilepath), {"--stop"}});
|
||||
m_process.setWorkingDirectory("/usr/bin");
|
||||
m_process.start();
|
||||
}
|
||||
|
||||
void QdbStopApplicationService::stopDeployment()
|
||||
@@ -121,7 +122,7 @@ void QdbStopApplicationService::stopDeployment()
|
||||
|
||||
void QdbStopApplicationService::cleanup()
|
||||
{
|
||||
m_applicationLauncher.disconnect(this);
|
||||
m_process.close();
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user