diff options
author | hjk <hjk@qt.io> | 2022-02-11 17:38:16 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2022-02-14 15:10:12 +0000 |
commit | 95c9579c58d8cd9dfacbeee70f84920ab9cf87e7 (patch) | |
tree | ecb272ad7451830ca0e8046aaa7cb8ec80018d48 | |
parent | 380d952221a1f87ed47b860a7eb5ed5f51cbf70e (diff) |
ProjectExplorer: Normalize DeviceProcess::start() signature
Change-Id: I2915be34d4a1eed64567874dcf0263b7583cc142
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
24 files changed, 108 insertions, 110 deletions
diff --git a/src/libs/utils/commandline.cpp b/src/libs/utils/commandline.cpp index df3d12b463b..c81e49b30f0 100644 --- a/src/libs/utils/commandline.cpp +++ b/src/libs/utils/commandline.cpp @@ -1478,6 +1478,12 @@ void CommandLine::addCommandLineAsArgs(const CommandLine &cmd) addArgs(cmd.splitArguments()); } +void CommandLine::addCommandLineAsArgs(const CommandLine &cmd, RawType) +{ + addArg(cmd.executable().path()); + addArgs(cmd.arguments(), Raw); +} + void CommandLine::addArgs(const QString &inArgs, RawType) { ProcessArgs::addArgs(&m_arguments, inArgs); diff --git a/src/libs/utils/commandline.h b/src/libs/utils/commandline.h index c5408c45b12..068e724dfd4 100644 --- a/src/libs/utils/commandline.h +++ b/src/libs/utils/commandline.h @@ -145,6 +145,7 @@ public: void addArgs(const QStringList &inArgs); void addCommandLineAsArgs(const CommandLine &cmd); + void addCommandLineAsArgs(const CommandLine &cmd, RawType); void addArgs(const QString &inArgs, RawType); diff --git a/src/libs/utils/qtcprocess.cpp b/src/libs/utils/qtcprocess.cpp index 35526b4f6f5..ebe02d4ebc8 100644 --- a/src/libs/utils/qtcprocess.cpp +++ b/src/libs/utils/qtcprocess.cpp @@ -635,6 +635,7 @@ public: bool m_haveEnv = false; bool m_useCtrlCStub = false; ProcessSetupData m_setup; + QVariantHash m_extraData; void slotTimeout(); void slotFinished(int exitCode, QProcess::ExitStatus e); @@ -910,6 +911,26 @@ QString QtcProcess::toStandaloneCommandLine() const return parts.join(" "); } +void QtcProcess::setExtraData(const QString &key, const QVariant &value) +{ + d->m_extraData.insert(key, value); +} + +QVariant QtcProcess::extraData(const QString &key) const +{ + return d->m_extraData.value(key); +} + +void QtcProcess::setExtraData(const QVariantHash &extraData) +{ + d->m_extraData = extraData; +} + +QVariantHash QtcProcess::extraData() const +{ + return d->m_extraData; +} + void QtcProcess::setRemoteProcessHooks(const DeviceProcessHooks &hooks) { s_deviceHooks = hooks; diff --git a/src/libs/utils/qtcprocess.h b/src/libs/utils/qtcprocess.h index 9aaeb450d86..7e807bb58b5 100644 --- a/src/libs/utils/qtcprocess.h +++ b/src/libs/utils/qtcprocess.h @@ -126,7 +126,7 @@ public: void setAbortOnMetaChars(bool abort); - void start(); + virtual void start(); virtual void terminate(); virtual void interrupt(); @@ -222,6 +222,12 @@ public: QString toStandaloneCommandLine() const; + void setExtraData(const QString &key, const QVariant &value); + QVariant extraData(const QString &key) const; + + void setExtraData(const QVariantHash &extraData); + QVariantHash extraData() const; + signals: void started(); void finished(); diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp index 016cd7f78e4..921c901346a 100644 --- a/src/plugins/docker/dockerdevice.cpp +++ b/src/plugins/docker/dockerdevice.cpp @@ -106,7 +106,7 @@ public: DockerDeviceProcess(const QSharedPointer<const IDevice> &device, QObject *parent = nullptr); ~DockerDeviceProcess() {} - void start(const Runnable &runnable) override; + void start() override; void interrupt() override; }; @@ -117,13 +117,13 @@ DockerDeviceProcess::DockerDeviceProcess(const QSharedPointer<const IDevice> &de setProcessMode(ProcessMode::Writer); } -void DockerDeviceProcess::start(const Runnable &runnable) +void DockerDeviceProcess::start() { QTC_ASSERT(state() == QProcess::NotRunning, return); DockerDevice::ConstPtr dockerDevice = qSharedPointerCast<const DockerDevice>(device()); QTC_ASSERT(dockerDevice, return); - const QStringList dockerRunFlags = runnable.extraData[Constants::DOCKER_RUN_FLAGS].toStringList(); + const QStringList dockerRunFlags = extraData(Constants::DOCKER_RUN_FLAGS).toStringList(); connect(this, &DeviceProcess::readyReadStandardOutput, this, [this] { MessageManager::writeSilently(QString::fromLocal8Bit(readAllStandardError())); @@ -132,15 +132,12 @@ void DockerDeviceProcess::start(const Runnable &runnable) MessageManager::writeDisrupting(QString::fromLocal8Bit(readAllStandardError())); }); - CommandLine command = runnable.command; + CommandLine command = commandLine(); command.setExecutable( command.executable().withNewPath(dockerDevice->mapToDevicePath(command.executable()))); setCommand(command); - setEnvironment(runnable.environment); - setWorkingDirectory(runnable.workingDirectory); - LOG("Running process:" << command.toUserOutput() - << "in" << runnable.workingDirectory.toUserOutput()); + LOG("Running process:" << command.toUserOutput() << "in" << workingDirectory().toUserOutput()); dockerDevice->runProcess(*this); } diff --git a/src/plugins/perfprofiler/perfconfigwidget.cpp b/src/plugins/perfprofiler/perfconfigwidget.cpp index b58900c5d60..c5aacbacbdf 100644 --- a/src/plugins/perfprofiler/perfconfigwidget.cpp +++ b/src/plugins/perfprofiler/perfconfigwidget.cpp @@ -173,9 +173,8 @@ void PerfConfigWidget::readTracePoints() messageBox.setText(tr("Replace events with trace points read from the device?")); messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); if (messageBox.exec() == QMessageBox::Yes) { - ProjectExplorer::Runnable runnable; - runnable.command = {"perf", {"probe", "-l"}}; - m_process->start(runnable); + m_process->setCommand({"perf", {"probe", "-l"}}); + m_process->start(); useTracePointsButton->setEnabled(false); } } diff --git a/src/plugins/perfprofiler/perfprofilerruncontrol.cpp b/src/plugins/perfprofiler/perfprofilerruncontrol.cpp index 684918bb6a8..edd445d8056 100644 --- a/src/plugins/perfprofiler/perfprofilerruncontrol.cpp +++ b/src/plugins/perfprofiler/perfprofilerruncontrol.cpp @@ -147,15 +147,13 @@ public: Runnable perfRunnable = runnable(); - QStringList arguments; - arguments << "record"; - arguments += m_perfRecordArguments; - arguments << "-o" << "-" << "--" << perfRunnable.command.executable().toString() - << ProcessArgs::splitArgs(perfRunnable.command.arguments(), OsTypeLinux); - - perfRunnable.command.setExecutable("perf"); - perfRunnable.command.setArguments(ProcessArgs::joinArgs(arguments, OsTypeLinux)); - m_process->start(perfRunnable); + CommandLine cmd({"perf", {"record"}}); + cmd.addArgs(m_perfRecordArguments); + cmd.addArgs({"-o", "-", "--"}); + cmd.addCommandLineAsArgs(perfRunnable.command, CommandLine::Raw); + + m_process->setCommand(cmd); + m_process->start(); } void stop() override diff --git a/src/plugins/perfprofiler/perftracepointdialog.cpp b/src/plugins/perfprofiler/perftracepointdialog.cpp index 3bb2197ea58..6b3d46cf7ee 100644 --- a/src/plugins/perfprofiler/perftracepointdialog.cpp +++ b/src/plugins/perfprofiler/perftracepointdialog.cpp @@ -100,12 +100,11 @@ void PerfTracePointDialog::runScript() m_process.reset(m_device->createProcess(this)); - Runnable runnable; const QString elevate = m_ui->privilegesChooser->currentText(); if (elevate != QLatin1String("n.a.")) - runnable.command = {FilePath::fromString(elevate), {"sh"}}; + m_process->setCommand({FilePath::fromString(elevate), {"sh"}}); else - runnable.command = {"sh", {}}; + m_process->setCommand({"sh", {}}); connect(m_process.get(), &DeviceProcess::started, this, &PerfTracePointDialog::feedScriptToProcess); @@ -116,7 +115,7 @@ void PerfTracePointDialog::runScript() connect(m_process.get(), &DeviceProcess::errorOccurred, this, &PerfTracePointDialog::handleProcessError); - m_process->start(runnable); + m_process->start(); } void PerfTracePointDialog::feedScriptToProcess() diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp index 1f9bb0a8b2b..b1807d07ceb 100644 --- a/src/plugins/projectexplorer/applicationlauncher.cpp +++ b/src/plugins/projectexplorer/applicationlauncher.cpp @@ -422,7 +422,11 @@ void ApplicationLauncherPrivate::start(const Runnable &runnable, const IDevice:: this, &ApplicationLauncherPrivate::handleApplicationError); connect(m_deviceProcess, &DeviceProcess::finished, this, &ApplicationLauncherPrivate::handleApplicationFinished); - m_deviceProcess->start(runnable); + m_deviceProcess->setCommand(runnable.command); + m_deviceProcess->setWorkingDirectory(runnable.workingDirectory); + m_deviceProcess->setEnvironment(runnable.environment); + m_deviceProcess->setExtraData(runnable.extraData); + m_deviceProcess->start(); } } diff --git a/src/plugins/projectexplorer/devicesupport/desktopdeviceprocess.cpp b/src/plugins/projectexplorer/devicesupport/desktopdeviceprocess.cpp index 064bb107e7d..57c013c4fee 100644 --- a/src/plugins/projectexplorer/devicesupport/desktopdeviceprocess.cpp +++ b/src/plugins/projectexplorer/devicesupport/desktopdeviceprocess.cpp @@ -44,16 +44,6 @@ DesktopDeviceProcess::DesktopDeviceProcess(const QSharedPointer<const IDevice> & setProcessMode(ProcessMode::Writer); } -void DesktopDeviceProcess::start(const Runnable &runnable) -{ - QTC_ASSERT(state() == QProcess::NotRunning, return); - if (runnable.environment.size()) - setEnvironment(runnable.environment); - setWorkingDirectory(runnable.workingDirectory); - setCommand(runnable.command); - QtcProcess::start(); -} - void DesktopDeviceProcess::interrupt() { device()->signalOperation()->interruptProcess(processId()); diff --git a/src/plugins/projectexplorer/devicesupport/desktopdeviceprocess.h b/src/plugins/projectexplorer/devicesupport/desktopdeviceprocess.h index ed926112a2d..779cd06178b 100644 --- a/src/plugins/projectexplorer/devicesupport/desktopdeviceprocess.h +++ b/src/plugins/projectexplorer/devicesupport/desktopdeviceprocess.h @@ -39,7 +39,6 @@ class DesktopDeviceProcess : public DeviceProcess public: DesktopDeviceProcess(const QSharedPointer<const IDevice> &device, QObject *parent = nullptr); - void start(const Runnable &runnable) override; void interrupt() override; }; diff --git a/src/plugins/projectexplorer/devicesupport/deviceprocess.h b/src/plugins/projectexplorer/devicesupport/deviceprocess.h index 20d14eff590..277a2dab1a5 100644 --- a/src/plugins/projectexplorer/devicesupport/deviceprocess.h +++ b/src/plugins/projectexplorer/devicesupport/deviceprocess.h @@ -30,19 +30,14 @@ #include <utils/qtcprocess.h> #include <QSharedPointer> -#include <QStringList> namespace ProjectExplorer { class IDevice; -class Runnable; class PROJECTEXPLORER_EXPORT DeviceProcess : public Utils::QtcProcess { Q_OBJECT -public: - using Utils::QtcProcess::start; - virtual void start(const Runnable &runnable) = 0; protected: explicit DeviceProcess(const QSharedPointer<const IDevice> &device, diff --git a/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp b/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp index 567cf5d41f5..ebee22824ca 100644 --- a/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp +++ b/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp @@ -86,9 +86,8 @@ void DeviceUsedPortsGatherer::start(const IDevice::ConstPtr &device) connect(d->process.data(), &DeviceProcess::readyReadStandardError, this, &DeviceUsedPortsGatherer::handleRemoteStdErr); - Runnable runnable; - runnable.command = d->portsGatheringMethod->commandLine(protocol); - d->process->start(runnable); + d->process->setCommand(d->portsGatheringMethod->commandLine(protocol)); + d->process->start(); } void DeviceUsedPortsGatherer::stop() diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp index e88aa414d1c..da1281d7e66 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp @@ -54,7 +54,8 @@ public: bool ignoreSelfSignals = true; QSsh::SshConnection *connection = nullptr; QSsh::SshRemoteProcessPtr remoteProcess; - Runnable runnable; + QString processName; + QString displayName; QString errorMessage; QProcess::ExitStatus exitStatus = QProcess::NormalExit; DeviceProcessSignalOperation::Ptr killOperation; @@ -63,11 +64,6 @@ public: void setState(State newState); void doSignal(Signal signal); - - QString displayName() const - { - return runnable.extraData.value("Ssh.X11ForwardToDisplay").toString(); - } }; SshDeviceProcess::SshDeviceProcess(const IDevice::ConstPtr &device, QObject *parent) @@ -95,17 +91,19 @@ SshDeviceProcess::~SshDeviceProcess() d->setState(SshDeviceProcessPrivate::Inactive); } -void SshDeviceProcess::start(const Runnable &runnable) +void SshDeviceProcess::start() { QTC_ASSERT(d->state == SshDeviceProcessPrivate::Inactive, return); - QTC_ASSERT(usesTerminal() || !runnable.command.isEmpty(), return); + QTC_ASSERT(usesTerminal() || !commandLine().isEmpty(), return); d->setState(SshDeviceProcessPrivate::Connecting); d->errorMessage.clear(); d->exitStatus = QProcess::NormalExit; - d->runnable = runnable; + d->processName = commandLine().executable().toString(); + d->displayName = extraData("Ssh.X11ForwardToDisplay").toString(); + QSsh::SshConnectionParameters params = device()->sshParameters(); - params.x11DisplayName = d->displayName(); + params.x11DisplayName = d->displayName; d->connection = QSsh::SshConnectionManager::acquireConnection(params); connect(d->connection, &QSsh::SshConnection::errorOccurred, this, &SshDeviceProcess::handleConnectionError); @@ -191,10 +189,10 @@ void SshDeviceProcess::handleConnected() QTC_ASSERT(d->state == SshDeviceProcessPrivate::Connecting, return); d->setState(SshDeviceProcessPrivate::Connected); - d->remoteProcess = usesTerminal() && d->runnable.command.isEmpty() + d->remoteProcess = usesTerminal() && d->processName.isEmpty() ? d->connection->createRemoteShell() - : d->connection->createRemoteProcess(fullCommandLine(d->runnable)); - const QString display = d->displayName(); + : d->connection->createRemoteProcess(fullCommandLine()); + const QString display = d->displayName; if (!display.isEmpty()) d->remoteProcess->requestX11Forwarding(display); d->ignoreSelfSignals = !usesTerminal(); @@ -280,18 +278,14 @@ void SshDeviceProcess::handleKillOperationTimeout() emit finished(); } -QString SshDeviceProcess::fullCommandLine(const Runnable &runnable) const +QString SshDeviceProcess::fullCommandLine() const { - QString cmdLine = runnable.command.executable().toString(); - // FIXME: That quotes wrongly. - if (!runnable.command.arguments().isEmpty()) - cmdLine.append(QLatin1Char(' ')).append(runnable.command.arguments()); - return cmdLine; + return commandLine().toUserOutput(); } void SshDeviceProcess::SshDeviceProcessPrivate::doSignal(Signal signal) { - if (runnable.command.isEmpty()) + if (processName.isEmpty()) return; switch (state) { case SshDeviceProcessPrivate::Inactive: @@ -310,7 +304,7 @@ void SshDeviceProcess::SshDeviceProcessPrivate::doSignal(Signal signal) if (processId != 0) signalOperation->interruptProcess(processId); else - signalOperation->interruptProcess(runnable.command.executable().toString()); + signalOperation->interruptProcess(processName); } else { if (killOperation) // We are already in the process of killing the app. return; @@ -321,7 +315,7 @@ void SshDeviceProcess::SshDeviceProcessPrivate::doSignal(Signal signal) if (processId != 0) signalOperation->killProcess(processId); else - signalOperation->killProcess(runnable.command.executable().toString()); + signalOperation->killProcess(processName); } break; } diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h index 0980d530bcf..9cd3368fd6b 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h @@ -31,8 +31,6 @@ namespace ProjectExplorer { -class Runnable; - class PROJECTEXPLORER_EXPORT SshDeviceProcess : public DeviceProcess { Q_OBJECT @@ -40,7 +38,7 @@ public: explicit SshDeviceProcess(const QSharedPointer<const IDevice> &device, QObject *parent = nullptr); ~SshDeviceProcess() override; - void start(const Runnable &runnable) override; + void start() override; void interrupt() override; void terminate() override; void kill() override; @@ -64,7 +62,7 @@ private: void handleKillOperationFinished(const QString &errorMessage); void handleKillOperationTimeout(); - virtual QString fullCommandLine(const Runnable &runnable) const; + virtual QString fullCommandLine() const; virtual qint64 processId() const; class SshDeviceProcessPrivate; diff --git a/src/plugins/projectexplorer/runcontrol.h b/src/plugins/projectexplorer/runcontrol.h index c1ab5d67813..a75b6ec1fad 100644 --- a/src/plugins/projectexplorer/runcontrol.h +++ b/src/plugins/projectexplorer/runcontrol.h @@ -71,7 +71,7 @@ public: Utils::FilePath workingDirectory; Utils::Environment environment; IDevice::ConstPtr device; // Override the kit's device. Keep unset by default. - QHash<Utils::Id, QVariant> extraData; + QVariantHash extraData; // FIXME: Not necessarily a display name QString displayName() const; diff --git a/src/plugins/qnx/qnxdevice.cpp b/src/plugins/qnx/qnxdevice.cpp index 764355b1e1e..3734f85574e 100644 --- a/src/plugins/qnx/qnxdevice.cpp +++ b/src/plugins/qnx/qnxdevice.cpp @@ -104,9 +104,8 @@ void QnxDevice::updateVersionNumber() const QObject::connect(&versionNumberProcess, &SshDeviceProcess::finished, &eventLoop, &QEventLoop::quit); QObject::connect(&versionNumberProcess, &DeviceProcess::errorOccurred, &eventLoop, &QEventLoop::quit); - Runnable r; - r.command = {"uname", {"-r"}}; - versionNumberProcess.start(r); + versionNumberProcess.setCommand({"uname", {"-r"}}); + versionNumberProcess.start(); bool isGuiThread = QThread::currentThread() == QCoreApplication::instance()->thread(); if (isGuiThread) diff --git a/src/plugins/qnx/qnxdeviceprocess.cpp b/src/plugins/qnx/qnxdeviceprocess.cpp index 0a272c3d001..c04b9dd6d74 100644 --- a/src/plugins/qnx/qnxdeviceprocess.cpp +++ b/src/plugins/qnx/qnxdeviceprocess.cpp @@ -44,21 +44,22 @@ QnxDeviceProcess::QnxDeviceProcess(const QSharedPointer<const IDevice> &device, m_pidFile = QString::fromLatin1("/var/run/qtc.%1.pid").arg(++pidFileCounter); } -QString QnxDeviceProcess::fullCommandLine(const Runnable &runnable) const +QString QnxDeviceProcess::fullCommandLine() const { - QStringList args = ProcessArgs::splitArgs(runnable.command.arguments()); - args.prepend(runnable.command.executable().toString()); + const CommandLine command = commandLine(); + QStringList args = ProcessArgs::splitArgs(command.arguments()); + args.prepend(command.executable().toString()); QString cmd = ProcessArgs::createUnixArgs(args).toString(); QString fullCommandLine = "test -f /etc/profile && . /etc/profile ; " "test -f $HOME/profile && . $HOME/profile ; "; - if (!runnable.workingDirectory.isEmpty()) + if (!workingDirectory().isEmpty()) fullCommandLine += QString::fromLatin1("cd %1 ; ").arg( - ProcessArgs::quoteArg(runnable.workingDirectory.toString())); + ProcessArgs::quoteArg(workingDirectory().toString())); - const Environment env = runnable.environment; + const Environment env = environment(); for (auto it = env.constBegin(); it != env.constEnd(); ++it) { fullCommandLine += QString::fromLatin1("%1='%2' ") .arg(env.key(it)).arg(env.expandedValueForKey(env.key(it))); @@ -72,11 +73,10 @@ QString QnxDeviceProcess::fullCommandLine(const Runnable &runnable) const void QnxDeviceProcess::doSignal(int sig) { auto signaler = new SshDeviceProcess(device(), this); - Runnable r; const QString args = QString("-%2 `cat %1`").arg(m_pidFile).arg(sig); - r.command = CommandLine(FilePath::fromString("kill"), args, CommandLine::Raw); + signaler->setCommand({"kill", args, CommandLine::Raw}); connect(signaler, &SshDeviceProcess::finished, signaler, &QObject::deleteLater); - signaler->start(r); + signaler->start(); } } // namespace Internal diff --git a/src/plugins/qnx/qnxdeviceprocess.h b/src/plugins/qnx/qnxdeviceprocess.h index eeffad6fbb4..52de0d275ba 100644 --- a/src/plugins/qnx/qnxdeviceprocess.h +++ b/src/plugins/qnx/qnxdeviceprocess.h @@ -40,7 +40,7 @@ public: void interrupt() override { doSignal(2); } void terminate() override { doSignal(15); } void kill() override { doSignal(9); } - QString fullCommandLine(const ProjectExplorer::Runnable &runnable) const override; + QString fullCommandLine() const override; private: void doSignal(int sig); diff --git a/src/plugins/qnx/slog2inforunner.cpp b/src/plugins/qnx/slog2inforunner.cpp index c5209fdfe54..75fb31cf014 100644 --- a/src/plugins/qnx/slog2inforunner.cpp +++ b/src/plugins/qnx/slog2inforunner.cpp @@ -70,9 +70,8 @@ void Slog2InfoRunner::printMissingWarning() void Slog2InfoRunner::start() { - Runnable r; - r.command = {"slog2info", {}}; - m_testProcess->start(r); + m_testProcess->setCommand({"slog2info", {}}); + m_testProcess->start(); reportStarted(); } @@ -108,9 +107,8 @@ void Slog2InfoRunner::handleTestProcessCompleted() void Slog2InfoRunner::readLaunchTime() { - Runnable r; - r.command = CommandLine("date", "+\"%d %H:%M:%S\"", CommandLine::Raw); - m_launchDateTimeProcess->start(r); + m_launchDateTimeProcess->setCommand({"date", "+\"%d %H:%M:%S\"", CommandLine::Raw}); + m_launchDateTimeProcess->start(); } void Slog2InfoRunner::launchSlog2Info() @@ -124,9 +122,8 @@ void Slog2InfoRunner::launchSlog2Info() m_launchDateTime = QDateTime::fromString(QString::fromLatin1(m_launchDateTimeProcess->readAllStandardOutput()).trimmed(), QString::fromLatin1("dd HH:mm:ss")); - Runnable r; - r.command = {"slog2info", {"-w"}}; - m_logProcess->start(r); + m_logProcess->setCommand({"slog2info", {"-w"}}); + m_logProcess->start(); } void Slog2InfoRunner::readLogStandardOutput() diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp index 98a262a31b8..34bedebc13e 100644 --- a/src/plugins/remotelinux/linuxdevice.cpp +++ b/src/plugins/remotelinux/linuxdevice.cpp @@ -329,18 +329,16 @@ LinuxDevice::LinuxDevice() Core::MessageManager::writeDisrupting(tr("Error starting remote shell.")); proc->deleteLater(); }); - Runnable runnable; - runnable.device = sharedFromThis(); - runnable.environment = env; - runnable.workingDirectory = workingDir; // It seems we cannot pass an environment to OpenSSH dynamically // without specifying an executable. if (env.size() > 0) - runnable.command.setExecutable("/bin/sh"); + proc->setCommand({"/bin/sh", {}}); proc->setTerminalMode(QtcProcess::TerminalOn); - proc->start(runnable); + proc->setEnvironment(env); + proc->setWorkingDirectory(workingDir); + proc->start(); }); if (Utils::HostOsInfo::isAnyUnixHost()) { diff --git a/src/plugins/remotelinux/linuxdeviceprocess.cpp b/src/plugins/remotelinux/linuxdeviceprocess.cpp index d8c69d77653..eb2e0742a47 100644 --- a/src/plugins/remotelinux/linuxdeviceprocess.cpp +++ b/src/plugins/remotelinux/linuxdeviceprocess.cpp @@ -79,7 +79,7 @@ qint64 LinuxDeviceProcess::processId() const return m_processId < 0 ? 0 : m_processId; } -QString LinuxDeviceProcess::fullCommandLine(const Runnable &runnable) const +QString LinuxDeviceProcess::fullCommandLine() const { CommandLine cmd; @@ -91,23 +91,22 @@ QString LinuxDeviceProcess::fullCommandLine(const Runnable &runnable) const cmd.addArgs(";", CommandLine::Raw); } - if (!runnable.workingDirectory.isEmpty()) { - cmd.addArgs({"cd", runnable.workingDirectory.path()}); + if (!workingDirectory().isEmpty()) { + cmd.addArgs({"cd", workingDirectory().path()}); cmd.addArgs("&&", CommandLine::Raw); } if (!usesTerminal()) cmd.addArgs(QString("echo ") + pidMarker + "$$" + pidMarker + " && ", CommandLine::Raw); - const Environment &env = runnable.environment; + const Environment &env = environment(); for (auto it = env.constBegin(); it != env.constEnd(); ++it) cmd.addArgs(env.key(it) + "='" + env.expandedValueForKey(env.key(it)) + '\'', CommandLine::Raw); if (!usesTerminal()) cmd.addArg("exec"); - cmd.addArg(runnable.command.executable().toString()); - cmd.addArgs(runnable.command.arguments(), CommandLine::Raw); + cmd.addCommandLineAsArgs(commandLine(), CommandLine::Raw); return cmd.arguments(); } diff --git a/src/plugins/remotelinux/linuxdeviceprocess.h b/src/plugins/remotelinux/linuxdeviceprocess.h index 2de4ceadf1e..5598b4b8bbb 100644 --- a/src/plugins/remotelinux/linuxdeviceprocess.h +++ b/src/plugins/remotelinux/linuxdeviceprocess.h @@ -43,7 +43,7 @@ public: QByteArray readAllStandardOutput() override; private: - QString fullCommandLine(const ProjectExplorer::Runnable &) const override; + QString fullCommandLine() const override; qint64 processId() const override; QByteArray m_output; diff --git a/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp b/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp index fd59e384317..d49e4584865 100644 --- a/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp +++ b/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp @@ -58,9 +58,8 @@ void RemoteLinuxEnvironmentReader::start() this, &RemoteLinuxEnvironmentReader::handleError); connect(m_deviceProcess, &DeviceProcess::finished, this, &RemoteLinuxEnvironmentReader::remoteProcessFinished); - Runnable runnable; - runnable.command.setExecutable("env"); - m_deviceProcess->start(runnable); + m_deviceProcess->setCommand({"env", {}}); + m_deviceProcess->start(); } void RemoteLinuxEnvironmentReader::stop() |