ApplicationLauncher: Remove start(IDevice *) overload

Take the device from runnable passed in setRunnable().
If the intention is to run locally, set the device
to nullptr inside runnable. Otherwise we don't run locally.

Follows 47957de2dc

Change-Id: I5b381bb499cf76e469c844ac7474ce2f60761cef
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Jarek Kobus
2022-02-23 14:41:23 +01:00
parent 8e0bc89e64
commit 10abf43afa
9 changed files with 36 additions and 41 deletions

View File

@@ -66,10 +66,11 @@ public:
{
ProjectExplorer::Runnable r;
r.command = {Constants::AppcontrollerFilepath, {"--stop"}};
r.device = device();
auto launcher = new ApplicationLauncher(this);
launcher->setRunnable(r);
launcher->start(device());
launcher->start();
}
};
@@ -91,8 +92,9 @@ public:
Runnable r;
r.command = command;
r.device = device;
m_appRunner.setRunnable(r);
m_appRunner.start(device);
m_appRunner.start();
showMessage(QdbDevice::tr("Starting command \"%1\" on device \"%2\".")
.arg(command.toUserOutput(), m_deviceName));
}

View File

@@ -117,9 +117,10 @@ public:
r.command.setArguments(args);
r.command.setExecutable(FilePath::fromString(Constants::AppcontrollerFilepath));
r.device = device();
m_launcher.setRunnable(r);
m_launcher.start(device());
m_launcher.start();
}
void stop() override { m_launcher.stop(); }

View File

@@ -98,9 +98,10 @@ void QdbStopApplicationService::doDeploy()
ProjectExplorer::Runnable runnable;
runnable.command = {Constants::AppcontrollerFilepath, {"--stop"}};
runnable.workingDirectory = "/usr/bin";
runnable.device = ProjectExplorer::DeviceKitAspect::device(target()->kit());
d->applicationLauncher.setRunnable(runnable);
d->applicationLauncher.start(ProjectExplorer::DeviceKitAspect::device(target()->kit()));
d->applicationLauncher.start();
}
void QdbStopApplicationService::stopDeployment()

View File

@@ -504,7 +504,8 @@ void QmlEngine::closeConnection()
void QmlEngine::startApplicationLauncher()
{
if (!d->applicationLauncher.isRunning()) {
const Runnable runnable = runParameters().inferior;
Runnable runnable = runParameters().inferior;
runnable.device.reset();
showMessage(tr("Starting %1").arg(runnable.command.toUserOutput()),
NormalMessageFormat);
d->applicationLauncher.setRunnable(runnable);

View File

@@ -70,7 +70,7 @@ public:
explicit ApplicationLauncherPrivate(ApplicationLauncher *parent);
~ApplicationLauncherPrivate() override { setFinished(); }
void start(const IDevice::ConstPtr &device, bool local);
void start();
void stop();
void handleStandardOutput();
@@ -324,17 +324,12 @@ QProcess::ExitStatus ApplicationLauncher::exitStatus() const
void ApplicationLauncher::start()
{
d->start(IDevice::ConstPtr(), true);
d->start();
}
void ApplicationLauncher::start(const IDevice::ConstPtr &device)
void ApplicationLauncherPrivate::start()
{
d->start(device, false);
}
void ApplicationLauncherPrivate::start(const IDevice::ConstPtr &device, bool local)
{
m_isLocal = local;
m_isLocal = m_runnable.device.isNull();
m_exitCode = 0;
m_exitStatus = QProcess::NormalExit;
@@ -381,19 +376,19 @@ void ApplicationLauncherPrivate::start(const IDevice::ConstPtr &device, bool loc
QTC_ASSERT(m_state == Inactive, return);
m_state = Run;
if (!device) {
if (!m_runnable.device) {
doReportError(ApplicationLauncher::tr("Cannot run: No device."));
setFinished();
return;
}
if (!device->canCreateProcess()) {
if (!m_runnable.device->canCreateProcess()) {
doReportError(ApplicationLauncher::tr("Cannot run: Device is not able to create processes."));
setFinished();
return;
}
if (!device->isEmptyCommandAllowed() && m_runnable.command.isEmpty()) {
if (!m_runnable.device->isEmptyCommandAllowed() && m_runnable.command.isEmpty()) {
doReportError(ApplicationLauncher::tr("Cannot run: No command given."));
setFinished();
return;
@@ -401,7 +396,7 @@ void ApplicationLauncherPrivate::start(const IDevice::ConstPtr &device, bool loc
m_stopRequested = false;
m_process.reset(device->createProcess(this));
m_process.reset(m_runnable.device->createProcess(this));
connect(m_process.get(), &QtcProcess::errorOccurred,
this, &ApplicationLauncherPrivate::handleApplicationError);
connect(m_process.get(), &QtcProcess::finished,

View File

@@ -58,7 +58,6 @@ public:
void setRunnable(const Runnable &runnable);
void start();
void start(const IDevice::ConstPtr &device);
void stop();
bool isRunning() const;
Utils::ProcessHandle applicationPID() const;

View File

@@ -1244,14 +1244,18 @@ void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstP
if (runnable.command.isEmpty()) {
reportFailure(RunControl::tr("No executable specified."));
} else {
m_launcher.setRunnable(runnable);
Runnable runnableWithoutDevice = runnable;
runnableWithoutDevice.device.reset();
m_launcher.setRunnable(runnableWithoutDevice);
m_launcher.start();
}
} else {
connect(&m_launcher, &ApplicationLauncher::processStarted, this, &RunWorker::reportStarted);
Runnable runnableWithDevice = runnable;
runnableWithDevice.device = device;
m_launcher.setRunnable(runnable);
m_launcher.start(device);
m_launcher.start();
}
}

View File

@@ -125,13 +125,12 @@ void CallgrindController::run(Option option)
Runnable controller = m_valgrindRunnable;
controller.command.setExecutable(FilePath::fromString(CALLGRIND_CONTROL_BINARY));
controller.command.setArguments(QString("%1 %2").arg(toOptionString(option)).arg(m_pid));
if (m_valgrindRunnable.device
&& m_valgrindRunnable.device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
controller.device = m_valgrindRunnable.device;
}
m_controllerProcess->setRunnable(controller);
if (!m_valgrindRunnable.device
|| m_valgrindRunnable.device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
m_controllerProcess->start();
else
m_controllerProcess->start(m_valgrindRunnable.device);
}
void CallgrindController::setValgrindPid(qint64 pid)

View File

@@ -135,20 +135,12 @@ bool ValgrindRunner::Private::run()
valgrind.command = cmd;
valgrind.workingDirectory = m_debuggee.workingDirectory;
valgrind.environment = m_debuggee.environment;
if (m_device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE
&& m_device->type() != "DockerDeviceType") {
valgrind.device = m_device;
if (m_device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
m_valgrindProcess.setRunnable(valgrind);
m_valgrindProcess.start();
} else if (m_device->type() == "DockerDeviceType") {
valgrind.device = {};
m_valgrindProcess.setRunnable(valgrind);
m_valgrindProcess.start();
} else {
m_valgrindProcess.setRunnable(valgrind);
m_valgrindProcess.start(m_device);
}
m_valgrindProcess.setRunnable(valgrind);
m_valgrindProcess.start();
return true;
}
@@ -192,12 +184,13 @@ void ValgrindRunner::Private::remoteProcessStarted()
" | awk '\\$5 ~ /^%3/" // 5th column must start with valgrind process
" {print \\$1;}'" // print 1st then (with PID)
"\"").arg(proc, m_debuggee.command.executable().fileName(), procEscaped));
findPid.device = m_device;
// m_remote.m_findPID = m_remote.m_connection->createRemoteProcess(cmd.toUtf8());
connect(&m_findPID, &ApplicationLauncher::appendMessage,
this, &ValgrindRunner::Private::findPidOutputReceived);
m_findPID.setRunnable(findPid);
m_findPID.start(m_device);
m_findPID.start();
}
void ValgrindRunner::Private::findPidOutputReceived(const QString &out, Utils::OutputFormat format)