From 3844f59806104516d6c1ae2ee3757f509066df9b Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 23 Aug 2019 15:31:35 +0200 Subject: [PATCH] ProjectExplorer: Standardize RunWorker creation logic This unifies the remaining paths of RunWorker creation to always use RunWorkerFactories in the plugin pimpls. There were, and are, still effectively three basic kinds of workers: - "toplevel" tools corresponding to the run modes, that are often all that's used for local runs and directly started via the fat buttons or e.g. entries in the analyze menu, with factories already previously located in the plugin pimpls - core "tool helpers", providing tool specific functionality typically used in conjunction with a remote device specific run mechanism, set up via RunControl::registerWorkerCreator - target/device specific runhelper like port gatherers contructed e.g. via *Device::workerCreator(Core::Id id) Worse, these categories are partially overlapping, so it was not clear how a "clean" setup would look like, instead some ad-hoc cobbling "to make it work" happened. In some cases, the runMode id was used throughout the whole ensemble of run workers for a given run, and which worker exactly was created depended on which of the mechanism above was used in which order. With the new central setup, the top-level runmodes remain, but the second kind gets new ids, so the implicit dependencies on order of setup mechanism are avoided. This also helps in the cases where there was previously unclarity of where and how to set up worker factories: It's always and only the plugin pimpl now. Change-Id: Icd9a08e2d53e19abe8b21fe546f469fae353a69f Reviewed-by: Ulf Hermann --- .../qmldebug/qmldebugcommandlinearguments.h | 23 +++++++ .../android/androidqmltoolingsupport.cpp | 2 +- src/plugins/android/androidrunnerworker.h | 2 +- src/plugins/boot2qt/qdbdevice.cpp | 12 ---- src/plugins/boot2qt/qdbdevice.h | 3 - src/plugins/boot2qt/qdbdevicedebugsupport.cpp | 6 +- src/plugins/boot2qt/qdbdevicedebugsupport.h | 19 +----- src/plugins/boot2qt/qdbplugin.cpp | 15 +++-- src/plugins/ios/iosrunner.cpp | 2 +- .../perfprofiler/perfprofilerplugin.cpp | 3 - .../perfprofiler/perfprofilerruncontrol.cpp | 5 +- src/plugins/perfprofiler/perfprofilertool.h | 2 +- .../devicesupport/deviceusedportsgatherer.cpp | 10 ++- .../projectexplorer/devicesupport/idevice.h | 4 -- .../projectexplorerconstants.h | 7 +- src/plugins/projectexplorer/runcontrol.cpp | 33 +++------ src/plugins/projectexplorer/runcontrol.h | 7 +- src/plugins/qmlpreview/qmlpreviewplugin.cpp | 67 ++++++++++--------- src/plugins/qmlprofiler/qmlprofilerplugin.cpp | 20 +++--- src/plugins/qnx/qnxanalyzesupport.cpp | 2 +- src/plugins/remotelinux/remotelinuxplugin.cpp | 13 ++-- .../remotelinuxqmltoolingsupport.cpp | 18 +++-- .../remotelinuxqmltoolingsupport.h | 21 +----- 23 files changed, 118 insertions(+), 178 deletions(-) diff --git a/src/libs/qmldebug/qmldebugcommandlinearguments.h b/src/libs/qmldebug/qmldebugcommandlinearguments.h index 8c70a368995..f3a60174930 100644 --- a/src/libs/qmldebug/qmldebugcommandlinearguments.h +++ b/src/libs/qmldebug/qmldebugcommandlinearguments.h @@ -25,6 +25,9 @@ #pragma once +#include +#include + #include #include @@ -85,4 +88,24 @@ inline QString qmlDebugLocalArguments(QmlDebugServicesPreset services, const QSt return qmlDebugCommandLineArguments(services, QLatin1String("file:") + socket, block); } +inline Core::Id runnerIdForRunMode(Core::Id runMode) +{ + if (runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) + return ProjectExplorer::Constants::QML_PROFILER_RUNNER; + if (runMode == ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE) + return ProjectExplorer::Constants::QML_PREVIEW_RUNNER; + return {}; +} + +inline QmlDebugServicesPreset servicesForRunMode(Core::Id runMode) +{ + if (runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) + return QmlDebug::QmlProfilerServices; + if (runMode == ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE) + return QmlDebug::QmlPreviewServices; + if (runMode == ProjectExplorer::Constants::DEBUG_RUN_MODE) + return QmlDebug::QmlDebuggerServices; + return {}; +} + } // namespace QmlDebug diff --git a/src/plugins/android/androidqmltoolingsupport.cpp b/src/plugins/android/androidqmltoolingsupport.cpp index b304fbde72e..0687201b672 100644 --- a/src/plugins/android/androidqmltoolingsupport.cpp +++ b/src/plugins/android/androidqmltoolingsupport.cpp @@ -40,7 +40,7 @@ AndroidQmlToolingSupport::AndroidQmlToolingSupport(RunControl *runControl, auto runner = new AndroidRunner(runControl, intentName); addStartDependency(runner); - auto profiler = runControl->createWorker(runControl->runMode()); + auto profiler = runControl->createWorker(QmlDebug::runnerIdForRunMode(runControl->runMode())); profiler->addStartDependency(this); connect(runner, &AndroidRunner::qmlServerReady, this, [this, profiler](const QUrl &server) { diff --git a/src/plugins/android/androidrunnerworker.h b/src/plugins/android/androidrunnerworker.h index 30da68fc2df..ead26eed705 100644 --- a/src/plugins/android/androidrunnerworker.h +++ b/src/plugins/android/androidrunnerworker.h @@ -26,7 +26,7 @@ #pragma once -#include +#include #include diff --git a/src/plugins/boot2qt/qdbdevice.cpp b/src/plugins/boot2qt/qdbdevice.cpp index 4a72a7c4a60..c6e388878d6 100644 --- a/src/plugins/boot2qt/qdbdevice.cpp +++ b/src/plugins/boot2qt/qdbdevice.cpp @@ -200,18 +200,6 @@ void QdbDevice::setupDefaultNetworkSettings(const QString &host) setSshParameters(parameters); } -std::function - QdbDevice::workerCreator(Core::Id id) const -{ - if (id == "PerfRecorder") { - return [](ProjectExplorer::RunControl *runControl) { - return new QdbDevicePerfProfilerSupport(runControl); - }; - } - return {}; -} - - // QdbDeviceWizard class QdbSettingsPage : public QWizardPage diff --git a/src/plugins/boot2qt/qdbdevice.h b/src/plugins/boot2qt/qdbdevice.h index d7a816097b5..a0f6f9338f3 100644 --- a/src/plugins/boot2qt/qdbdevice.h +++ b/src/plugins/boot2qt/qdbdevice.h @@ -52,9 +52,6 @@ public: void setupDefaultNetworkSettings(const QString &host); - std::function - workerCreator(Core::Id id) const override; - private: QdbDevice(); diff --git a/src/plugins/boot2qt/qdbdevicedebugsupport.cpp b/src/plugins/boot2qt/qdbdevicedebugsupport.cpp index 7ef38ad8322..c8c8c22349c 100644 --- a/src/plugins/boot2qt/qdbdevicedebugsupport.cpp +++ b/src/plugins/boot2qt/qdbdevicedebugsupport.cpp @@ -175,17 +175,17 @@ void QdbDeviceDebugSupport::stop() // QdbDeviceQmlProfilerSupport -QdbDeviceQmlToolingSupport::QdbDeviceQmlToolingSupport(RunControl *runControl, - QmlDebug::QmlDebugServicesPreset services) +QdbDeviceQmlToolingSupport::QdbDeviceQmlToolingSupport(RunControl *runControl) : RunWorker(runControl) { setId("QdbDeviceQmlToolingSupport"); + QmlDebug::QmlDebugServicesPreset services = QmlDebug::servicesForRunMode(runControl->runMode()); m_runner = new QdbDeviceInferiorRunner(runControl, false, false, true, services); addStartDependency(m_runner); addStopDependency(m_runner); - m_worker = runControl->createWorker(runControl->runMode()); + m_worker = runControl->createWorker(QmlDebug::runnerIdForRunMode(runControl->runMode())); m_worker->addStartDependency(this); addStopDependency(m_worker); } diff --git a/src/plugins/boot2qt/qdbdevicedebugsupport.h b/src/plugins/boot2qt/qdbdevicedebugsupport.h index 0f07b20f485..8ed779d3705 100644 --- a/src/plugins/boot2qt/qdbdevicedebugsupport.h +++ b/src/plugins/boot2qt/qdbdevicedebugsupport.h @@ -47,8 +47,7 @@ private: class QdbDeviceQmlToolingSupport : public ProjectExplorer::RunWorker { public: - QdbDeviceQmlToolingSupport(ProjectExplorer::RunControl *runControl, - QmlDebug::QmlDebugServicesPreset services); + QdbDeviceQmlToolingSupport(ProjectExplorer::RunControl *runControl); private: void start() override; @@ -57,22 +56,6 @@ private: ProjectExplorer::RunWorker *m_worker = nullptr; }; -class QdbDeviceQmlProfilerSupport : public QdbDeviceQmlToolingSupport -{ -public: - QdbDeviceQmlProfilerSupport(ProjectExplorer::RunControl *runControl) : - QdbDeviceQmlToolingSupport(runControl, QmlDebug::QmlProfilerServices) - {} -}; - -class QdbDeviceQmlPreviewSupport : public QdbDeviceQmlToolingSupport -{ -public: - QdbDeviceQmlPreviewSupport(ProjectExplorer::RunControl *runControl) : - QdbDeviceQmlToolingSupport(runControl, QmlDebug::QmlPreviewServices) - {} -}; - class QdbDevicePerfProfilerSupport : public ProjectExplorer::RunWorker { public: diff --git a/src/plugins/boot2qt/qdbplugin.cpp b/src/plugins/boot2qt/qdbplugin.cpp index 2a3c85f0851..804df7eab11 100644 --- a/src/plugins/boot2qt/qdbplugin.cpp +++ b/src/plugins/boot2qt/qdbplugin.cpp @@ -197,16 +197,17 @@ public: supportedRunConfigs, {Qdb::Constants::QdbLinuxOsType} }; - RunWorkerFactory qmlProfilerWorkerFactory{ - RunWorkerFactory::make(), - {ProjectExplorer::Constants::QML_PROFILER_RUN_MODE}, + RunWorkerFactory qmlToolWorkerFactory{ + RunWorkerFactory::make(), + {ProjectExplorer::Constants::QML_PROFILER_RUN_MODE, + ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE}, supportedRunConfigs, {Qdb::Constants::QdbLinuxOsType} }; - RunWorkerFactory qmlPreviewWorkerFactory{ - RunWorkerFactory::make(), - {ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE}, - supportedRunConfigs, + RunWorkerFactory perfRecorderFactory{ + RunWorkerFactory::make(), + {"PerfRecorder"}, + {}, {Qdb::Constants::QdbLinuxOsType} }; diff --git a/src/plugins/ios/iosrunner.cpp b/src/plugins/ios/iosrunner.cpp index 21879132ceb..7dde31be669 100644 --- a/src/plugins/ios/iosrunner.cpp +++ b/src/plugins/ios/iosrunner.cpp @@ -395,7 +395,7 @@ IosQmlProfilerSupport::IosQmlProfilerSupport(RunControl *runControl) m_runner->setQmlDebugging(QmlDebug::QmlProfilerServices); addStartDependency(m_runner); - m_profiler = runControl->createWorker(runControl->runMode()); + m_profiler = runControl->createWorker(ProjectExplorer::Constants::QML_PROFILER_RUNNER); m_profiler->addStartDependency(this); } diff --git a/src/plugins/perfprofiler/perfprofilerplugin.cpp b/src/plugins/perfprofiler/perfprofilerplugin.cpp index d6f791b553e..e9440e61419 100644 --- a/src/plugins/perfprofiler/perfprofilerplugin.cpp +++ b/src/plugins/perfprofiler/perfprofilerplugin.cpp @@ -66,9 +66,6 @@ public: PerfProfilerPluginPrivate() { RunConfiguration::registerAspect(); - - RunControl::registerWorkerCreator(ProjectExplorer::Constants::PERFPROFILER_RUN_MODE, - [](RunControl *runControl){ return new PerfProfilerRunner(runControl); }); } RunWorkerFactory profilerWorkerFactory{ diff --git a/src/plugins/perfprofiler/perfprofilerruncontrol.cpp b/src/plugins/perfprofiler/perfprofilerruncontrol.cpp index 5fde98538ed..b39509cbbe8 100644 --- a/src/plugins/perfprofiler/perfprofilerruncontrol.cpp +++ b/src/plugins/perfprofiler/perfprofilerruncontrol.cpp @@ -185,11 +185,10 @@ PerfProfilerRunner::PerfProfilerRunner(RunControl *runControl) // If the parser is gone, there is no point in going on. m_perfParserWorker->setEssential(true); - if (auto perfRecorder = device()->workerCreator("PerfRecorder")) { - m_perfRecordWorker = perfRecorder(runControl); - + if ((m_perfRecordWorker = runControl->createWorker("PerfRecorder"))) { m_perfParserWorker->addStartDependency(m_perfRecordWorker); addStartDependency(m_perfParserWorker); + } else { m_perfRecordWorker = new LocalPerfRecordWorker(runControl); diff --git a/src/plugins/perfprofiler/perfprofilertool.h b/src/plugins/perfprofiler/perfprofilertool.h index 8f36cfc7d00..57b71f2d1ea 100644 --- a/src/plugins/perfprofiler/perfprofilertool.h +++ b/src/plugins/perfprofiler/perfprofilertool.h @@ -32,7 +32,7 @@ #include "perftimelinemodelmanager.h" #include -#include +#include #include #include diff --git a/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp b/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp index 746fb8fd504..377be1d5206 100644 --- a/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp +++ b/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp @@ -267,8 +267,8 @@ public: m_portGatherer = qobject_cast(sharedEndpointGatherer); if (m_portGatherer) { - if (auto creator = device()->workerCreator("ChannelForwarder")) { - m_channelForwarder = qobject_cast(creator(runControl)); + if (auto forwarder = runControl->createWorker("ChannelForwarder")) { + m_channelForwarder = qobject_cast(forwarder); if (m_channelForwarder) { m_channelForwarder->addStartDependency(m_portGatherer); m_channelForwarder->setFromUrlGetter([this] { @@ -338,11 +338,9 @@ ChannelProvider::ChannelProvider(RunControl *runControl, int requiredChannels) { setId("ChannelProvider"); - RunWorker *sharedEndpoints = nullptr; - if (auto sharedEndpointGatherer = device()->workerCreator("SharedEndpointGatherer")) { + RunWorker *sharedEndpoints = runControl->createWorker("SharedEndpointGatherer"); + if (!sharedEndpoints) { // null is a legit value indicating 'no need to share'. - sharedEndpoints = sharedEndpointGatherer(runControl); - } else { sharedEndpoints = new PortsGatherer(runControl); } diff --git a/src/plugins/projectexplorer/devicesupport/idevice.h b/src/plugins/projectexplorer/devicesupport/idevice.h index aeb1bc23228..65e739950f6 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.h +++ b/src/plugins/projectexplorer/devicesupport/idevice.h @@ -60,8 +60,6 @@ class DeviceProcess; class DeviceProcessList; class Kit; class Runnable; -class RunControl; -class RunWorker; namespace Internal { class IDevicePrivate; } @@ -182,8 +180,6 @@ public: virtual DeviceProcessSignalOperation::Ptr signalOperation() const = 0; virtual DeviceEnvironmentFetcher::Ptr environmentFetcher() const; - virtual std::function workerCreator(Core::Id) const { return {}; } - enum DeviceState { DeviceReadyToUse, DeviceConnected, DeviceDisconnected, DeviceStateUnknown }; DeviceState deviceState() const; void setDeviceState(const DeviceState state); diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index 10ce33cb7fa..c76f1acda1d 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -198,10 +198,13 @@ const char GENERATOR_ID_PREFIX[] = "PE.Wizard.Generator."; // RunMode const char NO_RUN_MODE[]="RunConfiguration.NoRunMode"; const char NORMAL_RUN_MODE[]="RunConfiguration.NormalRunMode"; -const char QML_PROFILER_RUN_MODE[]="RunConfiguration.QmlProfilerRunMode"; -const char PERFPROFILER_RUN_MODE[]="PerfProfiler.RunMode"; const char DEBUG_RUN_MODE[]="RunConfiguration.DebugRunMode"; +const char QML_PROFILER_RUN_MODE[]="RunConfiguration.QmlProfilerRunMode"; +const char QML_PROFILER_RUNNER[]="RunConfiguration.QmlProfilerRunner"; const char QML_PREVIEW_RUN_MODE[]="RunConfiguration.QmlPreviewRunMode"; +const char QML_PREVIEW_RUNNER[]="RunConfiguration.QmlPreviewRunner"; +const char PERFPROFILER_RUN_MODE[]="PerfProfiler.RunMode"; +const char PERFPROFILER_RUNNER[]="PerfProfiler.Runner"; // Navigation Widget const char PROJECTTREE_ID[] = "Projects"; diff --git a/src/plugins/projectexplorer/runcontrol.cpp b/src/plugins/projectexplorer/runcontrol.cpp index 0afc1a93d34..29d9dc5d263 100644 --- a/src/plugins/projectexplorer/runcontrol.cpp +++ b/src/plugins/projectexplorer/runcontrol.cpp @@ -448,32 +448,15 @@ void RunControl::initiateFinish() QTimer::singleShot(0, d.get(), &RunControlPrivate::initiateFinish); } -using WorkerCreators = QHash; - -static WorkerCreators &theWorkerCreators() +RunWorker *RunControl::createWorker(Core::Id workerId) { - static WorkerCreators creators; - return creators; -} - -void RunControl::registerWorkerCreator(Core::Id id, const WorkerCreator &workerCreator) -{ - theWorkerCreators().insert(id, workerCreator); - auto keys = theWorkerCreators().keys(); - Q_UNUSED(keys) -} - -RunWorker *RunControl::createWorker(Core::Id id) -{ - auto keys = theWorkerCreators().keys(); - Q_UNUSED(keys) - WorkerCreator creator = theWorkerCreators().value(id); - if (creator) - return creator(this); - creator = device()->workerCreator(id); - if (creator) - return creator(this); - return nullptr; + const auto check = std::bind(&RunWorkerFactory::canRun, + std::placeholders::_1, + workerId, + DeviceTypeKitAspect::deviceTypeId(d->kit), + QString{}); + RunWorkerFactory *factory = Utils::findOrDefault(g_runWorkerFactories, check); + return factory ? factory->producer()(this) : nullptr; } bool RunControl::createMainWorker() diff --git a/src/plugins/projectexplorer/runcontrol.h b/src/plugins/projectexplorer/runcontrol.h index 1d8ead5fa7e..b3f3cf37fc8 100644 --- a/src/plugins/projectexplorer/runcontrol.h +++ b/src/plugins/projectexplorer/runcontrol.h @@ -251,12 +251,7 @@ public: const QString &cancelButtonText = QString(), bool *prompt = nullptr); - RunWorker *createWorker(Core::Id id); - - using WorkerCreator = RunWorkerFactory::WorkerCreator; - using Constraint = std::function; - - static void registerWorkerCreator(Core::Id id, const WorkerCreator &workerCreator); + RunWorker *createWorker(Core::Id workerId); bool createMainWorker(); static bool canRun(Core::Id runMode, Core::Id deviceType, Core::Id runConfigId); diff --git a/src/plugins/qmlpreview/qmlpreviewplugin.cpp b/src/plugins/qmlpreview/qmlpreviewplugin.cpp index 5f833a4bc56..876cdb962a5 100644 --- a/src/plugins/qmlpreview/qmlpreviewplugin.cpp +++ b/src/plugins/qmlpreview/qmlpreviewplugin.cpp @@ -142,7 +142,40 @@ public: float m_zoomFactor = -1.0; QmlPreview::QmlPreviewFpsHandler m_fpsHandler = nullptr; QString m_locale; - std::unique_ptr m_runWorkerFactory; + + RunWorkerFactory localRunWorkerFactory{ + RunWorkerFactory::make(), + {Constants::QML_PREVIEW_RUN_MODE}, + {}, // All runconfig. + {Constants::DESKTOP_DEVICE_TYPE} + }; + + RunWorkerFactory runWorkerFactory{ + [this](RunControl *runControl) { + QmlPreviewRunner *runner = new QmlPreviewRunner(runControl, m_fileLoader, m_fileClassifer, + m_fpsHandler, m_zoomFactor, m_locale); + connect(q, &QmlPreviewPlugin::updatePreviews, + runner, &QmlPreviewRunner::loadFile); + connect(q, &QmlPreviewPlugin::rerunPreviews, + runner, &QmlPreviewRunner::rerun); + connect(runner, &QmlPreviewRunner::ready, + this, &QmlPreviewPluginPrivate::previewCurrentFile); + connect(q, &QmlPreviewPlugin::zoomFactorChanged, + runner, &QmlPreviewRunner::zoom); + connect(q, &QmlPreviewPlugin::localeChanged, + runner, &QmlPreviewRunner::language); + + connect(runner, &RunWorker::started, this, [this, runControl] { + addPreview(runControl); + }); + connect(runner, &RunWorker::stopped, this, [this, runControl] { + removePreview(runControl); + }); + + return runner; + }, + {Constants::QML_PREVIEW_RUNNER} + }; }; QmlPreviewPluginPrivate::QmlPreviewPluginPrivate(QmlPreviewPlugin *parent) @@ -152,13 +185,6 @@ QmlPreviewPluginPrivate::QmlPreviewPluginPrivate(QmlPreviewPlugin *parent) m_fileClassifer = &defaultFileClassifier; m_fpsHandler = &defaultFpsHandler; - m_runWorkerFactory.reset(new RunWorkerFactory{ - RunWorkerFactory::make(), - {Constants::QML_PREVIEW_RUN_MODE}, - {}, // All runconfig. - {Constants::DESKTOP_DEVICE_TYPE} - }); - Core::ActionContainer *menu = Core::ActionManager::actionContainer( Constants::M_BUILDPROJECT); QAction *action = new QAction(QmlPreviewPlugin::tr("QML Preview"), this); @@ -199,31 +225,6 @@ QmlPreviewPluginPrivate::QmlPreviewPluginPrivate(QmlPreviewPlugin *parent) connect(q, &QmlPreviewPlugin::previewedFileChanged, this, &QmlPreviewPluginPrivate::checkFile); connect(parser, &QmlPreviewParser::success, this, &QmlPreviewPluginPrivate::triggerPreview); - RunControl::registerWorkerCreator(Constants::QML_PREVIEW_RUN_MODE, - [this](RunControl *runControl) { - QmlPreviewRunner *runner = new QmlPreviewRunner(runControl, m_fileLoader, m_fileClassifer, - m_fpsHandler, m_zoomFactor, m_locale); - QObject::connect(q, &QmlPreviewPlugin::updatePreviews, - runner, &QmlPreviewRunner::loadFile); - QObject::connect(q, &QmlPreviewPlugin::rerunPreviews, - runner, &QmlPreviewRunner::rerun); - QObject::connect(runner, &QmlPreviewRunner::ready, - this, &QmlPreviewPluginPrivate::previewCurrentFile); - QObject::connect(q, &QmlPreviewPlugin::zoomFactorChanged, - runner, &QmlPreviewRunner::zoom); - QObject::connect(q, &QmlPreviewPlugin::localeChanged, - runner, &QmlPreviewRunner::language); - - QObject::connect(runner, &RunWorker::started, this, [this, runControl]() { - addPreview(runControl); - }); - QObject::connect(runner, &RunWorker::stopped, this, [this, runControl]() { - removePreview(runControl); - }); - - return runner; - }); - attachToEditor(); } diff --git a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp index b961a5827b8..f53c604285d 100644 --- a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp @@ -86,12 +86,22 @@ public: QmlProfilerTool m_profilerTool; QmlProfilerOptionsPage m_profilerOptionsPage; QmlProfilerActions m_actions; - RunWorkerFactory m_profilerWorkerFactory{ + + // The full local profiler. + RunWorkerFactory localQmlProfilerFactory { RunWorkerFactory::make(), {ProjectExplorer::Constants::QML_PROFILER_RUN_MODE}, {}, {ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE} }; + + // The bits plugged in in remote setups. + RunWorkerFactory qmlProfilerWorkerFactory { + RunWorkerFactory::make(), + {ProjectExplorer::Constants::QML_PROFILER_RUNNER}, + {}, + {} + }; }; bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString) @@ -107,14 +117,6 @@ void QmlProfilerPlugin::extensionsInitialized() d->m_actions.registerActions(); RunConfiguration::registerAspect(); - - RunControl::registerWorkerCreator(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE, - [this](RunControl *runControl) { - auto runner = new QmlProfilerRunner(runControl); - connect(runner, &QmlProfilerRunner::starting, - &d->m_profilerTool, &QmlProfilerTool::finalizeRunControl); - return runner; - }); } ExtensionSystem::IPlugin::ShutdownFlag QmlProfilerPlugin::aboutToShutdown() diff --git a/src/plugins/qnx/qnxanalyzesupport.cpp b/src/plugins/qnx/qnxanalyzesupport.cpp index cab0bc7d573..8b5fc0c3369 100644 --- a/src/plugins/qnx/qnxanalyzesupport.cpp +++ b/src/plugins/qnx/qnxanalyzesupport.cpp @@ -59,7 +59,7 @@ QnxQmlProfilerSupport::QnxQmlProfilerSupport(RunControl *runControl) auto slog2InfoRunner = new Slog2InfoRunner(runControl); addStartDependency(slog2InfoRunner); - m_profiler = runControl->createWorker(runControl->runMode()); + m_profiler = runControl->createWorker(ProjectExplorer::Constants::QML_PROFILER_RUNNER); m_profiler->addStartDependency(this); addStopDependency(m_profiler); } diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp index 1f517802482..036750f4660 100644 --- a/src/plugins/remotelinux/remotelinuxplugin.cpp +++ b/src/plugins/remotelinux/remotelinuxplugin.cpp @@ -100,15 +100,10 @@ public: supportedRunConfigs, {Constants::GenericLinuxOsType} }; - RunWorkerFactory qmlProfilerFactory{ - RunWorkerFactory::make(), - {ProjectExplorer::Constants::QML_PROFILER_RUN_MODE}, - supportedRunConfigs, - {Constants::GenericLinuxOsType} - }; - RunWorkerFactory qmlPreviewFactory{ - RunWorkerFactory::make(), - {ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE}, + RunWorkerFactory qmlToolingFactory{ + RunWorkerFactory::make(), + {ProjectExplorer::Constants::QML_PROFILER_RUN_MODE, + ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE}, supportedRunConfigs, {Constants::GenericLinuxOsType} }; diff --git a/src/plugins/remotelinux/remotelinuxqmltoolingsupport.cpp b/src/plugins/remotelinux/remotelinuxqmltoolingsupport.cpp index 65194e3e96d..f12041c73d8 100644 --- a/src/plugins/remotelinux/remotelinuxqmltoolingsupport.cpp +++ b/src/plugins/remotelinux/remotelinuxqmltoolingsupport.cpp @@ -25,9 +25,7 @@ #include "remotelinuxqmltoolingsupport.h" -#include -#include -#include +#include using namespace ProjectExplorer; using namespace Utils; @@ -35,11 +33,8 @@ using namespace Utils; namespace RemoteLinux { namespace Internal { -// RemoteLinuxQmlProfilerSupport - -RemoteLinuxQmlToolingSupport::RemoteLinuxQmlToolingSupport( - RunControl *runControl, QmlDebug::QmlDebugServicesPreset services) - : SimpleTargetRunner(runControl), m_services(services) +RemoteLinuxQmlToolingSupport::RemoteLinuxQmlToolingSupport(RunControl *runControl) + : SimpleTargetRunner(runControl) { setId("RemoteLinuxQmlToolingSupport"); @@ -50,7 +45,7 @@ RemoteLinuxQmlToolingSupport::RemoteLinuxQmlToolingSupport( // be started before. addStopDependency(m_portsGatherer); - m_runworker = runControl->createWorker(runControl->runMode()); + m_runworker = runControl->createWorker(QmlDebug::runnerIdForRunMode(runControl->runMode())); m_runworker->addStartDependency(this); addStopDependency(m_runworker); } @@ -61,8 +56,11 @@ void RemoteLinuxQmlToolingSupport::start() m_runworker->recordData("QmlServerUrl", serverUrl); + QmlDebug::QmlDebugServicesPreset services = QmlDebug::servicesForRunMode(runControl()->runMode()); + Runnable r = runnable(); - QtcProcess::addArg(&r.commandLineArguments, QmlDebug::qmlDebugTcpArguments(m_services, serverUrl), + QtcProcess::addArg(&r.commandLineArguments, + QmlDebug::qmlDebugTcpArguments(services, serverUrl), device()->osType()); setRunnable(r); diff --git a/src/plugins/remotelinux/remotelinuxqmltoolingsupport.h b/src/plugins/remotelinux/remotelinuxqmltoolingsupport.h index 0677b425fc5..6c0c8c6b4cb 100644 --- a/src/plugins/remotelinux/remotelinuxqmltoolingsupport.h +++ b/src/plugins/remotelinux/remotelinuxqmltoolingsupport.h @@ -27,7 +27,6 @@ #include #include -#include namespace RemoteLinux { namespace Internal { @@ -35,31 +34,13 @@ namespace Internal { class RemoteLinuxQmlToolingSupport : public ProjectExplorer::SimpleTargetRunner { public: - RemoteLinuxQmlToolingSupport(ProjectExplorer::RunControl *runControl, - QmlDebug::QmlDebugServicesPreset services); + explicit RemoteLinuxQmlToolingSupport(ProjectExplorer::RunControl *runControl); private: void start() override; ProjectExplorer::PortsGatherer *m_portsGatherer; ProjectExplorer::RunWorker *m_runworker; - QmlDebug::QmlDebugServicesPreset m_services; -}; - -class RemoteLinuxQmlProfilerSupport : public RemoteLinuxQmlToolingSupport -{ -public: - RemoteLinuxQmlProfilerSupport(ProjectExplorer::RunControl *runControl) : - RemoteLinuxQmlToolingSupport(runControl, QmlDebug::QmlProfilerServices) - {} -}; - -class RemoteLinuxQmlPreviewSupport : public RemoteLinuxQmlToolingSupport -{ -public: - RemoteLinuxQmlPreviewSupport(ProjectExplorer::RunControl *runControl) : - RemoteLinuxQmlToolingSupport(runControl, QmlDebug::QmlPreviewServices) - {} }; } // namespace Internal