From 1d2ed65d938013d440176acfe8ac5bfb7b4f2e30 Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Wed, 17 Jan 2024 10:25:21 +0100 Subject: [PATCH] Create RunConfiguration specific QmlProfilerWorkerFactories Instead of relying on the QmlProfilerRunWorkerFactory to match for all RunConfiguration, every plugin needs to create a WorkerFactory for its own RunConfiguration. Similar to the SimpleTargetRunnerFactory there is now a SimpleQmlProfilerRunnerFactory which makes the setup easy. Change-Id: I504ca5afe232cb4e3aa0bb0b67271637a7e7a9d0 Reviewed-by: hjk --- .../projectexplorerconstants.h | 3 +++ .../qmlprofiler/qmlprofilerruncontrol.cpp | 4 ++++ .../qmlprofiler/qmlprofilerruncontrol.h | 19 ++++++++++++++++++- .../qmlprojectmanager/qmlprojectplugin.cpp | 4 ++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index ead0c982221..fa3af0d3435 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -176,6 +176,9 @@ const char QML_PREVIEW_RUNNER[]="RunConfiguration.QmlPreviewRunner"; const char PERFPROFILER_RUN_MODE[]="PerfProfiler.RunMode"; const char PERFPROFILER_RUNNER[]="PerfProfiler.Runner"; +// RunWorkerFactory +const char QML_PROFILER_RUN_FACTORY[] = "RunWorkerFactory.LocalQmlProfilerSupport"; + // RunConfig const char QMAKE_RUNCONFIG_ID[] = "Qt4ProjectManager.Qt4RunConfiguration:"; const char QBS_RUNCONFIG_ID[] = "Qbs.RunConfiguration:"; diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp index 4d04aea2900..b405bdd40f3 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp @@ -255,9 +255,13 @@ class LocalQmlProfilerRunWorkerFactory final : public RunWorkerFactory public: LocalQmlProfilerRunWorkerFactory() { + setId(ProjectExplorer::Constants::QML_PROFILER_RUN_FACTORY); setProduct(); addSupportedRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); addSupportedDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE); + addSupportedRunConfig(ProjectExplorer::Constants::QMAKE_RUNCONFIG_ID); + addSupportedRunConfig(ProjectExplorer::Constants::QBS_RUNCONFIG_ID); + addSupportedRunConfig(ProjectExplorer::Constants::CMAKE_RUNCONFIG_ID); } }; diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h index 4dbbdf6600c..fedc693b6e8 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h @@ -6,13 +6,15 @@ #include "qmlprofilerstatemanager.h" #include +#include #include #include #include -namespace QmlProfiler::Internal { +namespace QmlProfiler { +namespace Internal { class QmlProfilerRunner : public ProjectExplorer::RunWorker { @@ -53,3 +55,18 @@ public: void setupQmlProfilerRunning(); } // QmlProfiler::Internal + +class SimpleQmlProfilerRunnerFactory final : public ProjectExplorer::RunWorkerFactory +{ +public: + explicit SimpleQmlProfilerRunnerFactory(const QList &runConfigs, const QList &extraRunModes = {}) + { + cloneProduct(ProjectExplorer::Constants::QML_PROFILER_RUN_FACTORY); + addSupportedRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); + for (const Utils::Id &id : extraRunModes) + addSupportedRunMode(id); + setSupportedRunConfigs(runConfigs); + } +}; + +} // QmlProfiler diff --git a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp index 7ccda14659a..956079820ae 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp @@ -33,6 +33,8 @@ #include #include +#include + #include #include @@ -57,6 +59,7 @@ #include using namespace Core; +using namespace QmlProfiler; using namespace Debugger; using namespace ProjectExplorer; using namespace Utils; @@ -101,6 +104,7 @@ public: QmlProjectRunConfigurationFactory runConfigFactory; SimpleTargetRunnerFactory runWorkerFactory{{runConfigFactory.runConfigurationId()}}; SimpleDebugRunnerFactory debugRunWorkerFactory{{runConfigFactory.runConfigurationId()}}; + SimpleQmlProfilerRunnerFactory qmlProfilerRunWorkerFactory{{runConfigFactory.runConfigurationId()}}; QPointer lastMessageBox; QdsLandingPage *landingPage = nullptr; QdsLandingPageWidget *landingPageWidget = nullptr;