diff --git a/src/plugins/boot2qt/qdbdevice.cpp b/src/plugins/boot2qt/qdbdevice.cpp index 7b858747e50..2d69e4ce415 100644 --- a/src/plugins/boot2qt/qdbdevice.cpp +++ b/src/plugins/boot2qt/qdbdevice.cpp @@ -67,7 +67,9 @@ public: ProjectExplorer::Runnable r; r.command = {Constants::AppcontrollerFilepath, {"--stop"}}; - (new ApplicationLauncher(this))->start(r, device()); + auto launcher = new ApplicationLauncher(this); + launcher->setRunnable(r); + launcher->start(device()); } }; @@ -89,7 +91,8 @@ public: Runnable r; r.command = command; - m_appRunner.start(r, device); + m_appRunner.setRunnable(r); + m_appRunner.start(device); 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 153c21be453..91b334a442e 100644 --- a/src/plugins/boot2qt/qdbdevicedebugsupport.cpp +++ b/src/plugins/boot2qt/qdbdevicedebugsupport.cpp @@ -118,7 +118,8 @@ public: r.command.setArguments(args); r.command.setExecutable(FilePath::fromString(Constants::AppcontrollerFilepath)); - m_launcher.start(r, device()); + m_launcher.setRunnable(r); + m_launcher.start(device()); } void stop() override { m_launcher.stop(); } diff --git a/src/plugins/boot2qt/qdbstopapplicationservice.cpp b/src/plugins/boot2qt/qdbstopapplicationservice.cpp index 018e6bdbb70..9094f213d50 100644 --- a/src/plugins/boot2qt/qdbstopapplicationservice.cpp +++ b/src/plugins/boot2qt/qdbstopapplicationservice.cpp @@ -100,8 +100,8 @@ void QdbStopApplicationService::doDeploy() runnable.command = {Constants::AppcontrollerFilepath, {"--stop"}}; runnable.workingDirectory = "/usr/bin"; - d->applicationLauncher.start(runnable, - ProjectExplorer::DeviceKitAspect::device(target()->kit())); + d->applicationLauncher.setRunnable(runnable); + d->applicationLauncher.start(ProjectExplorer::DeviceKitAspect::device(target()->kit())); } void QdbStopApplicationService::stopDeployment() diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index db0df2dd232..9952b37ad00 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -507,7 +507,8 @@ void QmlEngine::startApplicationLauncher() const Runnable runnable = runParameters().inferior; showMessage(tr("Starting %1").arg(runnable.command.toUserOutput()), NormalMessageFormat); - d->applicationLauncher.start(runnable); + d->applicationLauncher.setRunnable(runnable); + d->applicationLauncher.start(); } } diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp index b1807d07ceb..619e5a26d14 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 Runnable &runnable, const IDevice::ConstPtr &device, bool local); + void start(const IDevice::ConstPtr &device, bool local); void stop(); // Local @@ -119,6 +119,8 @@ public: QProcess::ExitStatus m_remoteExitStatus = QProcess::CrashExit; State m_state = Inactive; bool m_stopRequested = false; + + Runnable m_runnable; }; } // Internal @@ -164,6 +166,11 @@ void ApplicationLauncher::setRunAsRoot(bool on) d->m_runAsRoot = on; } +void ApplicationLauncher::setRunnable(const Runnable &runnable) +{ + d->m_runnable = runnable; +} + void ApplicationLauncher::stop() { d->stop(); @@ -319,17 +326,17 @@ void ApplicationLauncherPrivate::handleProcessStarted() emit q->processStarted(); } -void ApplicationLauncher::start(const Runnable &runnable) +void ApplicationLauncher::start() { - d->start(runnable, IDevice::ConstPtr(), true); + d->start(IDevice::ConstPtr(), true); } -void ApplicationLauncher::start(const Runnable &runnable, const IDevice::ConstPtr &device) +void ApplicationLauncher::start(const IDevice::ConstPtr &device) { - d->start(runnable, device, false); + d->start(device, false); } -void ApplicationLauncherPrivate::start(const Runnable &runnable, const IDevice::ConstPtr &device, bool local) +void ApplicationLauncherPrivate::start(const IDevice::ConstPtr &device, bool local) { m_isLocal = local; @@ -358,10 +365,10 @@ void ApplicationLauncherPrivate::start(const Runnable &runnable, const IDevice:: // Work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch' ...) - const FilePath fixedPath = runnable.workingDirectory.normalizedPathName(); + const FilePath fixedPath = m_runnable.workingDirectory.normalizedPathName(); m_localProcess->setWorkingDirectory(fixedPath); - Environment env = runnable.environment; + Environment env = m_runnable.environment; if (m_runAsRoot) RunControl::provideAskPassEntry(env); @@ -373,7 +380,7 @@ void ApplicationLauncherPrivate::start(const Runnable &runnable, const IDevice:: WinDebugInterface::instance()->start(); // Try to start listener again... #endif - CommandLine cmdLine = runnable.command; + CommandLine cmdLine = m_runnable.command; if (HostOsInfo::isMacHost()) { CommandLine disclaim(Core::ICore::libexecPath("disclaim")); @@ -400,7 +407,7 @@ void ApplicationLauncherPrivate::start(const Runnable &runnable, const IDevice:: return; } - if (!device->isEmptyCommandAllowed() && runnable.command.isEmpty()) { + if (!device->isEmptyCommandAllowed() && m_runnable.command.isEmpty()) { doReportError(ApplicationLauncher::tr("Cannot run: No command given.")); setFinished(); return; @@ -422,10 +429,10 @@ void ApplicationLauncherPrivate::start(const Runnable &runnable, const IDevice:: this, &ApplicationLauncherPrivate::handleApplicationError); connect(m_deviceProcess, &DeviceProcess::finished, this, &ApplicationLauncherPrivate::handleApplicationFinished); - m_deviceProcess->setCommand(runnable.command); - m_deviceProcess->setWorkingDirectory(runnable.workingDirectory); - m_deviceProcess->setEnvironment(runnable.environment); - m_deviceProcess->setExtraData(runnable.extraData); + m_deviceProcess->setCommand(m_runnable.command); + m_deviceProcess->setWorkingDirectory(m_runnable.workingDirectory); + m_deviceProcess->setEnvironment(m_runnable.environment); + m_deviceProcess->setExtraData(m_runnable.extraData); m_deviceProcess->start(); } } diff --git a/src/plugins/projectexplorer/applicationlauncher.h b/src/plugins/projectexplorer/applicationlauncher.h index 86b9c6f3cf3..1582d5906ce 100644 --- a/src/plugins/projectexplorer/applicationlauncher.h +++ b/src/plugins/projectexplorer/applicationlauncher.h @@ -55,8 +55,10 @@ public: void setProcessChannelMode(QProcess::ProcessChannelMode mode); void setUseTerminal(bool on); void setRunAsRoot(bool on); - void start(const Runnable &runnable); - void start(const Runnable &runnable, const IDevice::ConstPtr &device); + 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 883760dfda0..884e53a8cd9 100644 --- a/src/plugins/projectexplorer/runcontrol.cpp +++ b/src/plugins/projectexplorer/runcontrol.cpp @@ -1245,12 +1245,14 @@ void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstP if (runnable.command.isEmpty()) { reportFailure(RunControl::tr("No executable specified.")); } else { - m_launcher.start(runnable); + m_launcher.setRunnable(runnable); + m_launcher.start(); } } else { connect(&m_launcher, &ApplicationLauncher::processStarted, this, &RunWorker::reportStarted); - m_launcher.start(runnable, device); + m_launcher.setRunnable(runnable); + m_launcher.start(device); } } diff --git a/src/plugins/valgrind/callgrind/callgrindcontroller.cpp b/src/plugins/valgrind/callgrind/callgrindcontroller.cpp index 83f98cc71bb..263d58d2357 100644 --- a/src/plugins/valgrind/callgrind/callgrindcontroller.cpp +++ b/src/plugins/valgrind/callgrind/callgrindcontroller.cpp @@ -126,11 +126,12 @@ void CallgrindController::run(Option option) controller.command.setExecutable(FilePath::fromString(CALLGRIND_CONTROL_BINARY)); controller.command.setArguments(QString("%1 %2").arg(toOptionString(option)).arg(m_pid)); + m_controllerProcess->setRunnable(controller); if (!m_valgrindRunnable.device || m_valgrindRunnable.device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) - m_controllerProcess->start(controller); + m_controllerProcess->start(); else - m_controllerProcess->start(controller, m_valgrindRunnable.device); + m_controllerProcess->start(m_valgrindRunnable.device); } void CallgrindController::setValgrindPid(qint64 pid) diff --git a/src/plugins/valgrind/valgrindrunner.cpp b/src/plugins/valgrind/valgrindrunner.cpp index 95cfcc0faf5..bfa59ab6202 100644 --- a/src/plugins/valgrind/valgrindrunner.cpp +++ b/src/plugins/valgrind/valgrindrunner.cpp @@ -138,12 +138,15 @@ bool ValgrindRunner::Private::run() valgrind.device = m_device; if (m_device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) { - m_valgrindProcess.start(valgrind); + m_valgrindProcess.setRunnable(valgrind); + m_valgrindProcess.start(); } else if (m_device->type() == "DockerDeviceType") { valgrind.device = {}; - m_valgrindProcess.start(valgrind); + m_valgrindProcess.setRunnable(valgrind); + m_valgrindProcess.start(); } else { - m_valgrindProcess.start(valgrind, m_device); + m_valgrindProcess.setRunnable(valgrind); + m_valgrindProcess.start(m_device); } return true; @@ -193,7 +196,8 @@ void ValgrindRunner::Private::remoteProcessStarted() // m_remote.m_findPID = m_remote.m_connection->createRemoteProcess(cmd.toUtf8()); connect(&m_findPID, &ApplicationLauncher::appendMessage, this, &ValgrindRunner::Private::findPidOutputReceived); - m_findPID.start(findPid, m_device); + m_findPID.setRunnable(findPid); + m_findPID.start(m_device); } void ValgrindRunner::Private::findPidOutputReceived(const QString &out, Utils::OutputFormat format)