diff --git a/src/plugins/boot2qt/qdbdevice.cpp b/src/plugins/boot2qt/qdbdevice.cpp index 269383f7bdb..a0ac528fa8e 100644 --- a/src/plugins/boot2qt/qdbdevice.cpp +++ b/src/plugins/boot2qt/qdbdevice.cpp @@ -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)); } diff --git a/src/plugins/boot2qt/qdbdevicedebugsupport.cpp b/src/plugins/boot2qt/qdbdevicedebugsupport.cpp index ef493fd0738..551090bfb90 100644 --- a/src/plugins/boot2qt/qdbdevicedebugsupport.cpp +++ b/src/plugins/boot2qt/qdbdevicedebugsupport.cpp @@ -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(); } diff --git a/src/plugins/boot2qt/qdbstopapplicationservice.cpp b/src/plugins/boot2qt/qdbstopapplicationservice.cpp index 192a8c542c0..0d973f24a9b 100644 --- a/src/plugins/boot2qt/qdbstopapplicationservice.cpp +++ b/src/plugins/boot2qt/qdbstopapplicationservice.cpp @@ -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() diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index 35217779b39..883289bb9f0 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -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); diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp index 2aacfd09809..282f61a642f 100644 --- a/src/plugins/projectexplorer/applicationlauncher.cpp +++ b/src/plugins/projectexplorer/applicationlauncher.cpp @@ -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, diff --git a/src/plugins/projectexplorer/applicationlauncher.h b/src/plugins/projectexplorer/applicationlauncher.h index c5272eba5bd..b3e833c22c7 100644 --- a/src/plugins/projectexplorer/applicationlauncher.h +++ b/src/plugins/projectexplorer/applicationlauncher.h @@ -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; diff --git a/src/plugins/projectexplorer/runcontrol.cpp b/src/plugins/projectexplorer/runcontrol.cpp index 2567e9ce63f..8be14b73d52 100644 --- a/src/plugins/projectexplorer/runcontrol.cpp +++ b/src/plugins/projectexplorer/runcontrol.cpp @@ -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(); } } diff --git a/src/plugins/valgrind/callgrind/callgrindcontroller.cpp b/src/plugins/valgrind/callgrind/callgrindcontroller.cpp index eaab4ce0376..e021f109977 100644 --- a/src/plugins/valgrind/callgrind/callgrindcontroller.cpp +++ b/src/plugins/valgrind/callgrind/callgrindcontroller.cpp @@ -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); + m_controllerProcess->start(); } void CallgrindController::setValgrindPid(qint64 pid) diff --git a/src/plugins/valgrind/valgrindrunner.cpp b/src/plugins/valgrind/valgrindrunner.cpp index d91c01847ed..a2d46ad43ea 100644 --- a/src/plugins/valgrind/valgrindrunner.cpp +++ b/src/plugins/valgrind/valgrindrunner.cpp @@ -135,20 +135,12 @@ bool ValgrindRunner::Private::run() valgrind.command = cmd; valgrind.workingDirectory = m_debuggee.workingDirectory; valgrind.environment = m_debuggee.environment; - 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); + if (m_device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE + && m_device->type() != "DockerDeviceType") { + valgrind.device = 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)