diff options
author | hjk <hjk@qt.io> | 2019-09-02 18:22:35 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2019-09-04 11:08:34 +0000 |
commit | 4028a41d2eb00649fb97c1f78be90a2cf42c7adf (patch) | |
tree | 2544a317c15722b849e5f4513f65160eced8b8fc /src/plugins | |
parent | 8d85a7c2bc011a06dff3a85e47b6ecfa5cdaed24 (diff) |
ProjectExplorer: Use std::function for SimpleTargetRunner::start()
This spares us the typical r = runnable(); modify(r); setRunnable(r)
roundtrip and the m_runnable storage that might or might not
be the same as runControl->runnable. Similar for m_device.
Change-Id: I8300260dd8dd7cd395e40bcd3d2ae45089085008
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/baremetal/baremetaldebugsupport.cpp | 17 | ||||
-rw-r--r-- | src/plugins/baremetal/baremetaldebugsupport.h | 2 | ||||
-rw-r--r-- | src/plugins/boot2qt/qdbplugin.cpp | 14 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerplugin.cpp | 1 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerruncontrol.cpp | 87 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerruncontrol.h | 5 | ||||
-rw-r--r-- | src/plugins/projectexplorer/runcontrol.cpp | 106 | ||||
-rw-r--r-- | src/plugins/projectexplorer/runcontrol.h | 20 | ||||
-rw-r--r-- | src/plugins/qmlpreview/qmlpreviewruncontrol.cpp | 12 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp | 44 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerruncontrol.h | 5 | ||||
-rw-r--r-- | src/plugins/qnx/qnxanalyzesupport.cpp | 38 | ||||
-rw-r--r-- | src/plugins/qnx/qnxanalyzesupport.h | 11 | ||||
-rw-r--r-- | src/plugins/qnx/qnxdebugsupport.cpp | 66 | ||||
-rw-r--r-- | src/plugins/remotelinux/remotelinuxqmltoolingsupport.cpp | 38 | ||||
-rw-r--r-- | src/plugins/remotelinux/remotelinuxqmltoolingsupport.h | 9 | ||||
-rw-r--r-- | src/plugins/webassembly/webassemblyrunconfiguration.cpp | 27 |
17 files changed, 217 insertions, 285 deletions
diff --git a/src/plugins/baremetal/baremetaldebugsupport.cpp b/src/plugins/baremetal/baremetaldebugsupport.cpp index 25eb81574b6..a8f20e197a2 100644 --- a/src/plugins/baremetal/baremetaldebugsupport.cpp +++ b/src/plugins/baremetal/baremetaldebugsupport.cpp @@ -54,6 +54,18 @@ namespace Internal { // BareMetalDebugSupport +class BareMetalGdbServer : public SimpleTargetRunner +{ +public: + BareMetalGdbServer(RunControl *runControl, const Runnable &runnable) + : SimpleTargetRunner(runControl) + { + setId("BareMetalGdbServer"); + // Baremetal's GDB servers are launched on the host, not on the target. + setStarter([this, runnable] { doStart(runnable, {}); }); + } +}; + BareMetalDebugSupport::BareMetalDebugSupport(RunControl *runControl) : Debugger::DebuggerRunTool(runControl) { @@ -75,9 +87,8 @@ BareMetalDebugSupport::BareMetalDebugSupport(RunControl *runControl) r.setCommandLine(p->command()); // Command arguments are in host OS style as the bare metal's GDB servers are launched // on the host, not on that target. - m_gdbServer = new SimpleTargetRunner(runControl); - m_gdbServer->setRunnable(r); - addStartDependency(m_gdbServer); + auto gdbServer = new BareMetalGdbServer(runControl, r); + addStartDependency(gdbServer); } } diff --git a/src/plugins/baremetal/baremetaldebugsupport.h b/src/plugins/baremetal/baremetaldebugsupport.h index 3a59343a9ea..cfc31017fb3 100644 --- a/src/plugins/baremetal/baremetaldebugsupport.h +++ b/src/plugins/baremetal/baremetaldebugsupport.h @@ -41,8 +41,6 @@ public: private: void start() final; - - ProjectExplorer::SimpleTargetRunner *m_gdbServer = nullptr; }; } // namespace Internal diff --git a/src/plugins/boot2qt/qdbplugin.cpp b/src/plugins/boot2qt/qdbplugin.cpp index 804df7eab11..8a07dbba6c7 100644 --- a/src/plugins/boot2qt/qdbplugin.cpp +++ b/src/plugins/boot2qt/qdbplugin.cpp @@ -138,15 +138,13 @@ class QdbDeviceRunSupport : public SimpleTargetRunner public: QdbDeviceRunSupport(RunControl *runControl) : SimpleTargetRunner(runControl) - {} - - void start() final { - Runnable r = runnable(); - r.commandLineArguments = r.executable.toString() + ' ' + r.commandLineArguments; - r.executable = Utils::FilePath::fromString(Constants::AppcontrollerFilepath); - setRunnable(r); - SimpleTargetRunner::start(); + setStarter([this, runControl] { + Runnable r = runControl->runnable(); + r.commandLineArguments = r.executable.toString() + ' ' + r.commandLineArguments; + r.executable = Utils::FilePath::fromString(Constants::AppcontrollerFilepath); + doStart(r, runControl->device()); + }); } }; diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index a3d622a6a34..c96c308f82d 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1656,7 +1656,6 @@ public: auto gdbServer = new GdbServerRunner(runControl, portsGatherer()); gdbServer->setUseMulti(false); - gdbServer->setDevice(runControl->device()); gdbServer->setAttachPid(ProcessHandle(pid)); addStartDependency(gdbServer); diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index d48f22ded8e..2b37030976f 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -1050,20 +1050,53 @@ QUrl GdbServerPortsGatherer::qmlServer() const // GdbServerRunner GdbServerRunner::GdbServerRunner(RunControl *runControl, GdbServerPortsGatherer *portsGatherer) - : SimpleTargetRunner(runControl), m_portsGatherer(portsGatherer) + : SimpleTargetRunner(runControl) { setId("GdbServerRunner"); - m_runnable = runControl->runnable(); - addStartDependency(m_portsGatherer); -} + const Runnable mainRunnable = runControl->runnable(); + addStartDependency(portsGatherer); -GdbServerRunner::~GdbServerRunner() = default; + QTC_ASSERT(portsGatherer, reportFailure(); return); -void GdbServerRunner::setRunnable(const Runnable &runnable) -{ - m_runnable = runnable; + setStarter([this, runControl, mainRunnable, portsGatherer] { + QTC_ASSERT(portsGatherer, reportFailure(); return); + + Runnable gdbserver; + gdbserver.environment = mainRunnable.environment; + gdbserver.workingDirectory = mainRunnable.workingDirectory; + + QStringList args = QtcProcess::splitArgs(mainRunnable.commandLineArguments, OsTypeLinux); + + const bool isQmlDebugging = portsGatherer->useQmlServer(); + const bool isCppDebugging = portsGatherer->useGdbServer(); + + if (isQmlDebugging) { + args.prepend(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices, + portsGatherer->qmlServer())); + } + if (isQmlDebugging && !isCppDebugging) { + gdbserver.executable = mainRunnable.executable; // FIXME: Case should not happen? + } else { + gdbserver.executable = FilePath::fromString(runControl->device()->debugServerPath()); + if (gdbserver.executable.isEmpty()) + gdbserver.executable = FilePath::fromString("gdbserver"); + args.clear(); + if (m_useMulti) + args.append("--multi"); + if (m_pid.isValid()) + args.append("--attach"); + args.append(QString(":%1").arg(portsGatherer->gdbServer().port())); + if (m_pid.isValid()) + args.append(QString::number(m_pid.pid())); + } + gdbserver.commandLineArguments = QtcProcess::joinArgs(args, OsTypeLinux); + + doStart(gdbserver, runControl->device()); + }); } +GdbServerRunner::~GdbServerRunner() = default; + void GdbServerRunner::setUseMulti(bool on) { m_useMulti = on; @@ -1074,42 +1107,4 @@ void GdbServerRunner::setAttachPid(ProcessHandle pid) m_pid = pid; } -void GdbServerRunner::start() -{ - QTC_ASSERT(m_portsGatherer, reportFailure(); return); - - Runnable gdbserver; - gdbserver.environment = m_runnable.environment; - gdbserver.workingDirectory = m_runnable.workingDirectory; - - QStringList args = QtcProcess::splitArgs(m_runnable.commandLineArguments, OsTypeLinux); - - const bool isQmlDebugging = m_portsGatherer->useQmlServer(); - const bool isCppDebugging = m_portsGatherer->useGdbServer(); - - if (isQmlDebugging) { - args.prepend(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices, - m_portsGatherer->qmlServer())); - } - if (isQmlDebugging && !isCppDebugging) { - gdbserver.executable = m_runnable.executable; // FIXME: Case should not happen? - } else { - gdbserver.executable = FilePath::fromString(device()->debugServerPath()); - if (gdbserver.executable.isEmpty()) - gdbserver.executable = FilePath::fromString("gdbserver"); - args.clear(); - if (m_useMulti) - args.append("--multi"); - if (m_pid.isValid()) - args.append("--attach"); - args.append(QString(":%1").arg(m_portsGatherer->gdbServer().port())); - if (m_pid.isValid()) - args.append(QString::number(m_pid.pid())); - } - gdbserver.commandLineArguments = QtcProcess::joinArgs(args, OsTypeLinux); - - SimpleTargetRunner::setRunnable(gdbserver); - SimpleTargetRunner::start(); -} - } // namespace Debugger diff --git a/src/plugins/debugger/debuggerruncontrol.h b/src/plugins/debugger/debuggerruncontrol.h index b0377cc5fb1..1db34fc0ee3 100644 --- a/src/plugins/debugger/debuggerruncontrol.h +++ b/src/plugins/debugger/debuggerruncontrol.h @@ -166,15 +166,10 @@ public: ~GdbServerRunner() override; - void setRunnable(const ProjectExplorer::Runnable &runnable); void setUseMulti(bool on); void setAttachPid(Utils::ProcessHandle pid); private: - void start() override; - - GdbServerPortsGatherer *m_portsGatherer; - ProjectExplorer::Runnable m_runnable; Utils::ProcessHandle m_pid; bool m_useMulti = true; }; diff --git a/src/plugins/projectexplorer/runcontrol.cpp b/src/plugins/projectexplorer/runcontrol.cpp index e21d70f064d..d31284d4347 100644 --- a/src/plugins/projectexplorer/runcontrol.cpp +++ b/src/plugins/projectexplorer/runcontrol.cpp @@ -1106,42 +1106,76 @@ SimpleTargetRunner::SimpleTargetRunner(RunControl *runControl) : RunWorker(runControl) { setId("SimpleTargetRunner"); - m_runnable = runControl->runnable(); // Default value. Can be overridden using setRunnable. - m_device = runControl->device(); // Default value. Can be overridden using setDevice. if (auto terminalAspect = runControl->aspect<TerminalAspect>()) m_useTerminal = terminalAspect->useTerminal(); } void SimpleTargetRunner::start() { + if (m_starter) + m_starter(); + else + doStart(runControl()->runnable(), runControl()->device()); +} + +void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstPtr &device) +{ m_stopReported = false; m_launcher.disconnect(this); m_launcher.setUseTerminal(m_useTerminal); - const bool isDesktop = m_device.isNull() || m_device.dynamicCast<const DesktopDevice>(); - const QString rawDisplayName = m_runnable.displayName(); + const bool isDesktop = device.isNull() || device.dynamicCast<const DesktopDevice>(); + const QString rawDisplayName = runnable.displayName(); const QString displayName = isDesktop ? QDir::toNativeSeparators(rawDisplayName) : rawDisplayName; const QString msg = RunControl::tr("Starting %1 %2...") - .arg(displayName).arg(m_runnable.commandLineArguments); + .arg(displayName).arg(runnable.commandLineArguments); appendMessage(msg, Utils::NormalMessageFormat); if (isDesktop) { connect(&m_launcher, &ApplicationLauncher::appendMessage, this, &SimpleTargetRunner::appendMessage); - connect(&m_launcher, &ApplicationLauncher::processStarted, - this, &SimpleTargetRunner::onProcessStarted); + + connect(&m_launcher, &ApplicationLauncher::processStarted, this, [this] { + // Console processes only know their pid after being started + ProcessHandle pid = m_launcher.applicationPID(); + runControl()->setApplicationProcessHandle(pid); + pid.activate(); + reportStarted(); + }); + connect(&m_launcher, &ApplicationLauncher::processExited, - this, &SimpleTargetRunner::onProcessFinished); + this, [this, displayName](int exitCode, QProcess::ExitStatus status) { + QString msg; + if (status == QProcess::CrashExit) + msg = tr("%1 crashed."); + else + msg = tr("%2 exited with code %1").arg(exitCode); + appendMessage(msg.arg(displayName), Utils::NormalMessageFormat); + if (!m_stopReported) { + m_stopReported = true; + reportStopped(); + } + }); + connect(&m_launcher, &ApplicationLauncher::error, - this, &SimpleTargetRunner::onProcessError); + this, [this, runnable](QProcess::ProcessError error) { + if (error == QProcess::Timedout) + return; // No actual change on the process side. + const QString msg = userMessageForProcessError(error, runnable.executable); + appendMessage(msg, Utils::NormalMessageFormat); + if (!m_stopReported) { + m_stopReported = true; + reportStopped(); + } + }); - if (m_runnable.executable.isEmpty()) { + if (runnable.executable.isEmpty()) { reportFailure(RunControl::tr("No executable specified.")); } else { - m_launcher.start(m_runnable); + m_launcher.start(runnable); } } else { @@ -1189,7 +1223,7 @@ void SimpleTargetRunner::start() appendMessage(progressString, Utils::NormalMessageFormat); }); - m_launcher.start(m_runnable, device()); + m_launcher.start(runnable, device); } } @@ -1198,55 +1232,11 @@ void SimpleTargetRunner::stop() m_launcher.stop(); } -void SimpleTargetRunner::onProcessStarted() +void SimpleTargetRunner::setStarter(const std::function<void ()> &starter) { - // Console processes only know their pid after being started - ProcessHandle pid = m_launcher.applicationPID(); - runControl()->setApplicationProcessHandle(pid); - pid.activate(); - reportStarted(); + m_starter = starter; } -void SimpleTargetRunner::onProcessFinished(int exitCode, QProcess::ExitStatus status) -{ - QString msg; - if (status == QProcess::CrashExit) - msg = tr("%1 crashed."); - else - msg = tr("%2 exited with code %1").arg(exitCode); - appendMessage(msg.arg(m_runnable.displayName()), Utils::NormalMessageFormat); - if (!m_stopReported) { - m_stopReported = true; - reportStopped(); - } -} - -void SimpleTargetRunner::onProcessError(QProcess::ProcessError error) -{ - if (error == QProcess::Timedout) - return; // No actual change on the process side. - const QString msg = userMessageForProcessError(error, m_runnable.executable); - appendMessage(msg, Utils::NormalMessageFormat); - if (!m_stopReported) { - m_stopReported = true; - reportStopped(); - } -} - -IDevice::ConstPtr SimpleTargetRunner::device() const -{ - return m_device; -} - -void SimpleTargetRunner::setRunnable(const Runnable &runnable) -{ - m_runnable = runnable; -} - -void SimpleTargetRunner::setDevice(const IDevice::ConstPtr &device) -{ - m_device = device; -} // RunWorkerPrivate diff --git a/src/plugins/projectexplorer/runcontrol.h b/src/plugins/projectexplorer/runcontrol.h index 794d305fc11..3f3e78968c5 100644 --- a/src/plugins/projectexplorer/runcontrol.h +++ b/src/plugins/projectexplorer/runcontrol.h @@ -279,23 +279,19 @@ class PROJECTEXPLORER_EXPORT SimpleTargetRunner : public RunWorker public: explicit SimpleTargetRunner(RunControl *runControl); - void setRunnable(const Runnable &runnable); - - void setDevice(const IDevice::ConstPtr &device); - IDevice::ConstPtr device() const; - protected: - void start() override; - void stop() override; + void setStarter(const std::function<void()> &starter); + void doStart(const Runnable &runnable, const IDevice::ConstPtr &device); private: - void onProcessStarted(); - void onProcessFinished(int exitCode, QProcess::ExitStatus status); - void onProcessError(QProcess::ProcessError error); + void start() final; + void stop() final; + + const Runnable &runnable() const = delete; ApplicationLauncher m_launcher; - Runnable m_runnable; - IDevice::ConstPtr m_device; + std::function<void()> m_starter; + bool m_stopReported = false; bool m_useTerminal = false; }; diff --git a/src/plugins/qmlpreview/qmlpreviewruncontrol.cpp b/src/plugins/qmlpreview/qmlpreviewruncontrol.cpp index d755c2fc6c9..13b5c5e4a2c 100644 --- a/src/plugins/qmlpreview/qmlpreviewruncontrol.cpp +++ b/src/plugins/qmlpreview/qmlpreviewruncontrol.cpp @@ -123,12 +123,14 @@ LocalQmlPreviewSupport::LocalQmlPreviewSupport(ProjectExplorer::RunControl *runC addStopDependency(preview); addStartDependency(preview); - ProjectExplorer::Runnable run = runnable(); + setStarter([this, runControl, serverUrl] { + ProjectExplorer::Runnable run = runControl->runnable(); - Utils::QtcProcess::addArg(&run.commandLineArguments, - QmlDebug::qmlDebugLocalArguments(QmlDebug::QmlPreviewServices, - serverUrl.path())); - setRunnable(run); + Utils::QtcProcess::addArg(&run.commandLineArguments, + QmlDebug::qmlDebugLocalArguments(QmlDebug::QmlPreviewServices, + serverUrl.path())); + doStart(run, {}); + }); } } // namespace QmlPreview diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp index d01bb52818b..5d51540d3f5 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp @@ -229,38 +229,36 @@ LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl, const Q { setId("LocalQmlProfilerSupport"); - m_profiler = new QmlProfilerRunner(runControl); - m_profiler->setServerUrl(serverUrl); + auto profiler = new QmlProfilerRunner(runControl); + profiler->setServerUrl(serverUrl); - addStopDependency(m_profiler); + addStopDependency(profiler); // We need to open the local server before the application tries to connect. // In the TCP case, it doesn't hurt either to start the profiler before. - addStartDependency(m_profiler); -} + addStartDependency(profiler); -void LocalQmlProfilerSupport::start() -{ - Runnable debuggee = runnable(); + setStarter([this, runControl, profiler, serverUrl] { + Runnable debuggee = runControl->runnable(); - QUrl serverUrl = m_profiler->serverUrl(); - QString code; - if (serverUrl.scheme() == Utils::urlSocketScheme()) - code = QString("file:%1").arg(serverUrl.path()); - else if (serverUrl.scheme() == Utils::urlTcpScheme()) - code = QString("port:%1").arg(serverUrl.port()); - else - QTC_CHECK(false); + QUrl serverUrl = profiler->serverUrl(); + QString code; + if (serverUrl.scheme() == Utils::urlSocketScheme()) + code = QString("file:%1").arg(serverUrl.path()); + else if (serverUrl.scheme() == Utils::urlTcpScheme()) + code = QString("port:%1").arg(serverUrl.port()); + else + QTC_CHECK(false); - QString arguments = Utils::QtcProcess::quoteArg( - QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlProfilerServices, code, true)); + QString arguments = Utils::QtcProcess::quoteArg( + QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlProfilerServices, code, true)); - if (!debuggee.commandLineArguments.isEmpty()) - arguments += ' ' + debuggee.commandLineArguments; + if (!debuggee.commandLineArguments.isEmpty()) + arguments += ' ' + debuggee.commandLineArguments; - debuggee.commandLineArguments = arguments; + debuggee.commandLineArguments = arguments; - setRunnable(debuggee); - SimpleTargetRunner::start(); + doStart(debuggee, {}); + }); } } // namespace Internal diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h index d58b08b0986..b846306abdc 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h @@ -71,11 +71,6 @@ public: LocalQmlProfilerSupport(ProjectExplorer::RunControl *runControl); LocalQmlProfilerSupport(ProjectExplorer::RunControl *runControl, const QUrl &serverUrl); - -private: - void start() override; - - QmlProfilerRunner *m_profiler; }; } // namespace Internal diff --git a/src/plugins/qnx/qnxanalyzesupport.cpp b/src/plugins/qnx/qnxanalyzesupport.cpp index 8b5fc0c3369..bba9401fe9c 100644 --- a/src/plugins/qnx/qnxanalyzesupport.cpp +++ b/src/plugins/qnx/qnxanalyzesupport.cpp @@ -25,21 +25,14 @@ #include "qnxanalyzesupport.h" -#include "qnxdevice.h" -#include "qnxrunconfiguration.h" #include "slog2inforunner.h" #include <projectexplorer/devicesupport/deviceusedportsgatherer.h> -#include <projectexplorer/kitinformation.h> -#include <projectexplorer/target.h> #include <utils/qtcassert.h> #include <utils/qtcprocess.h> #include <qmldebug/qmldebugcommandlinearguments.h> -#include <qmldebug/qmloutputparser.h> - -#include <ssh/sshconnection.h> using namespace ProjectExplorer; using namespace Utils; @@ -53,30 +46,27 @@ QnxQmlProfilerSupport::QnxQmlProfilerSupport(RunControl *runControl) setId("QnxQmlProfilerSupport"); appendMessage(tr("Preparing remote side..."), Utils::LogMessageFormat); - m_portsGatherer = new PortsGatherer(runControl); - addStartDependency(m_portsGatherer); + auto portsGatherer = new PortsGatherer(runControl); + addStartDependency(portsGatherer); auto slog2InfoRunner = new Slog2InfoRunner(runControl); addStartDependency(slog2InfoRunner); - m_profiler = runControl->createWorker(ProjectExplorer::Constants::QML_PROFILER_RUNNER); - m_profiler->addStartDependency(this); - addStopDependency(m_profiler); -} - -void QnxQmlProfilerSupport::start() -{ - const QUrl serverUrl = m_portsGatherer->findEndPoint(); - m_profiler->recordData("QmlServerUrl", serverUrl); + auto profiler = runControl->createWorker(ProjectExplorer::Constants::QML_PROFILER_RUNNER); + profiler->addStartDependency(this); + addStopDependency(profiler); - Runnable r = runnable(); - QtcProcess::addArg(&r.commandLineArguments, - QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, serverUrl), - device()->osType()); + setStarter([this, runControl, portsGatherer, profiler] { + const QUrl serverUrl = portsGatherer->findEndPoint(); + profiler->recordData("QmlServerUrl", serverUrl); - setRunnable(r); + Runnable r = runControl->runnable(); + QtcProcess::addArg(&r.commandLineArguments, + QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, serverUrl), + Utils::OsTypeOtherUnix); - SimpleTargetRunner::start(); + doStart(r, runControl->device()); + }); } } // namespace Internal diff --git a/src/plugins/qnx/qnxanalyzesupport.h b/src/plugins/qnx/qnxanalyzesupport.h index 415459e3c10..bcf92ae0a0c 100644 --- a/src/plugins/qnx/qnxanalyzesupport.h +++ b/src/plugins/qnx/qnxanalyzesupport.h @@ -25,24 +25,15 @@ #pragma once -#include <projectexplorer/devicesupport/deviceusedportsgatherer.h> -#include <projectexplorer/runconfiguration.h> +#include <projectexplorer/runcontrol.h> namespace Qnx { namespace Internal { class QnxQmlProfilerSupport : public ProjectExplorer::SimpleTargetRunner { - Q_OBJECT - public: explicit QnxQmlProfilerSupport(ProjectExplorer::RunControl *runControl); - -private: - void start() override; - - ProjectExplorer::PortsGatherer *m_portsGatherer; - ProjectExplorer::RunWorker *m_profiler; }; } // namespace Internal diff --git a/src/plugins/qnx/qnxdebugsupport.cpp b/src/plugins/qnx/qnxdebugsupport.cpp index 8b5cde356a5..54a0c5c2238 100644 --- a/src/plugins/qnx/qnxdebugsupport.cpp +++ b/src/plugins/qnx/qnxdebugsupport.cpp @@ -97,34 +97,28 @@ class QnxDebuggeeRunner : public ProjectExplorer::SimpleTargetRunner { public: QnxDebuggeeRunner(RunControl *runControl, GdbServerPortsGatherer *portsGatherer) - : SimpleTargetRunner(runControl), m_portsGatherer(portsGatherer) + : SimpleTargetRunner(runControl) { setId("QnxDebuggeeRunner"); - } -private: - void start() final - { - Runnable r = runnable(); - QStringList arguments; - if (m_portsGatherer->useGdbServer()) { - int pdebugPort = m_portsGatherer->gdbServer().port(); - r.executable = FilePath::fromString(Constants::QNX_DEBUG_EXECUTABLE); - arguments.append(QString::number(pdebugPort)); - } - if (m_portsGatherer->useQmlServer()) { - arguments.append(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices, - m_portsGatherer->qmlServer())); - } - arguments.append(QtcProcess::splitArgs(r.commandLineArguments)); - r.commandLineArguments = QtcProcess::joinArgs(arguments); - - setRunnable(r); - - SimpleTargetRunner::start(); + setStarter([this, runControl, portsGatherer] { + Runnable r = runControl->runnable(); + QStringList arguments; + if (portsGatherer->useGdbServer()) { + int pdebugPort = portsGatherer->gdbServer().port(); + r.executable = FilePath::fromString(Constants::QNX_DEBUG_EXECUTABLE); + arguments.append(QString::number(pdebugPort)); + } + if (portsGatherer->useQmlServer()) { + arguments.append(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices, + portsGatherer->qmlServer())); + } + arguments.append(QtcProcess::splitArgs(r.commandLineArguments)); + r.commandLineArguments = QtcProcess::joinArgs(arguments); + + doStart(r, runControl->device()); + }); } - - GdbServerPortsGatherer *m_portsGatherer; }; @@ -197,26 +191,20 @@ class PDebugRunner : public ProjectExplorer::SimpleTargetRunner { public: PDebugRunner(RunControl *runControl, GdbServerPortsGatherer *portsGatherer) - : SimpleTargetRunner(runControl), m_portsGatherer(portsGatherer) + : SimpleTargetRunner(runControl) { setId("PDebugRunner"); - addStartDependency(m_portsGatherer); - } + addStartDependency(portsGatherer); -private: - void start() final - { - const int pdebugPort = m_portsGatherer->gdbServer().port(); - - Runnable r; - r.executable = FilePath::fromString(Constants::QNX_DEBUG_EXECUTABLE); - r.commandLineArguments = QString::number(pdebugPort); - setRunnable(r); + setStarter([this, runControl, portsGatherer] { + const int pdebugPort = portsGatherer->gdbServer().port(); - SimpleTargetRunner::start(); + Runnable r; + r.executable = FilePath::fromString(Constants::QNX_DEBUG_EXECUTABLE); + r.commandLineArguments = QString::number(pdebugPort); + doStart(r, runControl->device()); + }); } - - GdbServerPortsGatherer *m_portsGatherer; }; QnxAttachDebugSupport::QnxAttachDebugSupport(RunControl *runControl) diff --git a/src/plugins/remotelinux/remotelinuxqmltoolingsupport.cpp b/src/plugins/remotelinux/remotelinuxqmltoolingsupport.cpp index f12041c73d8..2dd5214617d 100644 --- a/src/plugins/remotelinux/remotelinuxqmltoolingsupport.cpp +++ b/src/plugins/remotelinux/remotelinuxqmltoolingsupport.cpp @@ -25,6 +25,8 @@ #include "remotelinuxqmltoolingsupport.h" +#include <projectexplorer/devicesupport/deviceusedportsgatherer.h> + #include <qmldebug/qmldebugcommandlinearguments.h> using namespace ProjectExplorer; @@ -38,34 +40,30 @@ RemoteLinuxQmlToolingSupport::RemoteLinuxQmlToolingSupport(RunControl *runContro { setId("RemoteLinuxQmlToolingSupport"); - m_portsGatherer = new PortsGatherer(runControl); - addStartDependency(m_portsGatherer); + auto portsGatherer = new PortsGatherer(runControl); + addStartDependency(portsGatherer); // The ports gatherer can safely be stopped once the process is running, even though it has to // be started before. - addStopDependency(m_portsGatherer); - - m_runworker = runControl->createWorker(QmlDebug::runnerIdForRunMode(runControl->runMode())); - m_runworker->addStartDependency(this); - addStopDependency(m_runworker); -} - -void RemoteLinuxQmlToolingSupport::start() -{ - const QUrl serverUrl = m_portsGatherer->findEndPoint(); + addStopDependency(portsGatherer); - m_runworker->recordData("QmlServerUrl", serverUrl); + auto runworker = runControl->createWorker(QmlDebug::runnerIdForRunMode(runControl->runMode())); + runworker->addStartDependency(this); + addStopDependency(runworker); - QmlDebug::QmlDebugServicesPreset services = QmlDebug::servicesForRunMode(runControl()->runMode()); + setStarter([this, runControl, portsGatherer, runworker] { + const QUrl serverUrl = portsGatherer->findEndPoint(); + runworker->recordData("QmlServerUrl", serverUrl); - Runnable r = runnable(); - QtcProcess::addArg(&r.commandLineArguments, - QmlDebug::qmlDebugTcpArguments(services, serverUrl), - device()->osType()); + QmlDebug::QmlDebugServicesPreset services = QmlDebug::servicesForRunMode(runControl->runMode()); - setRunnable(r); + Runnable r = runControl->runnable(); + QtcProcess::addArg(&r.commandLineArguments, + QmlDebug::qmlDebugTcpArguments(services, serverUrl), + OsTypeLinux); - SimpleTargetRunner::start(); + doStart(r, runControl->device()); + }); } } // namespace Internal diff --git a/src/plugins/remotelinux/remotelinuxqmltoolingsupport.h b/src/plugins/remotelinux/remotelinuxqmltoolingsupport.h index 6c0c8c6b4cb..9cfa927a0a1 100644 --- a/src/plugins/remotelinux/remotelinuxqmltoolingsupport.h +++ b/src/plugins/remotelinux/remotelinuxqmltoolingsupport.h @@ -25,8 +25,7 @@ #pragma once -#include <projectexplorer/devicesupport/deviceusedportsgatherer.h> -#include <projectexplorer/runconfiguration.h> +#include <projectexplorer/runcontrol.h> namespace RemoteLinux { namespace Internal { @@ -35,12 +34,6 @@ class RemoteLinuxQmlToolingSupport : public ProjectExplorer::SimpleTargetRunner { public: explicit RemoteLinuxQmlToolingSupport(ProjectExplorer::RunControl *runControl); - -private: - void start() override; - - ProjectExplorer::PortsGatherer *m_portsGatherer; - ProjectExplorer::RunWorker *m_runworker; }; } // namespace Internal diff --git a/src/plugins/webassembly/webassemblyrunconfiguration.cpp b/src/plugins/webassembly/webassemblyrunconfiguration.cpp index c6ead8ae216..b8f3610ccc0 100644 --- a/src/plugins/webassembly/webassemblyrunconfiguration.cpp +++ b/src/plugins/webassembly/webassemblyrunconfiguration.cpp @@ -91,23 +91,18 @@ public: EmrunRunWorker(RunControl *runControl) : SimpleTargetRunner(runControl) { - m_portsGatherer = new PortsGatherer(runControl); - addStartDependency(m_portsGatherer); - } - - void start() final - { - CommandLine cmd = emrunCommand(runControl()->target(), - runControl()->aspect<WebBrowserSelectionAspect>()->currentBrowser(), - QString::number(m_portsGatherer->findEndPoint().port())); - Runnable r; - r.setCommandLine(cmd); - setRunnable(r); - - SimpleTargetRunner::start(); + auto portsGatherer = new PortsGatherer(runControl); + addStartDependency(portsGatherer); + + setStarter([this, runControl, portsGatherer] { + CommandLine cmd = emrunCommand(runControl->target(), + runControl->aspect<WebBrowserSelectionAspect>()->currentBrowser(), + QString::number(portsGatherer->findEndPoint().port())); + Runnable r; + r.setCommandLine(cmd); + SimpleTargetRunner::doStart(r, {}); + }); } - - PortsGatherer *m_portsGatherer; }; RunWorkerFactory::WorkerCreator makeEmrunWorker() |