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