From 22886376680e70b8523675b46c33f1cb103a11c5 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 1 Feb 2024 14:50:06 +0100 Subject: [PATCH] Python: Use setup functions for run related items Change-Id: Iefbeda433b0f7eaaf3c429dbc853e0c8578ceb3a Reviewed-by: David Schulz --- src/plugins/python/pythonplugin.cpp | 6 ++-- src/plugins/python/pythonrunconfiguration.cpp | 34 +++++++++++++++++-- src/plugins/python/pythonrunconfiguration.h | 15 ++------ 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/src/plugins/python/pythonplugin.cpp b/src/plugins/python/pythonplugin.cpp index db914afc083..8410d31f9fb 100644 --- a/src/plugins/python/pythonplugin.cpp +++ b/src/plugins/python/pythonplugin.cpp @@ -43,9 +43,6 @@ QObject *pluginInstance() class PythonPluginPrivate { public: - PythonRunConfigurationFactory runConfigFactory; - SimpleTargetRunnerFactory runWorkerFactory{{runConfigFactory.runConfigurationId()}}; - SimpleDebugRunnerFactory debugRunWorkerFactory{{runConfigFactory.runConfigurationId()}, {ProjectExplorer::Constants::DAP_PY_DEBUG_RUN_MODE}}; PythonSettings settings; PythonWizardPageFactory pythonWizardPageFactory; }; @@ -77,6 +74,9 @@ private: setupPySideBuildStep(); setupPythonBuildConfiguration(); + setupPythonRunConfiguration(); + setupPythonRunWorker(); + setupPythonDebugWorker(); setupPythonOutputParser(); KitManager::setIrrelevantAspects(KitManager::irrelevantAspects() diff --git a/src/plugins/python/pythonrunconfiguration.cpp b/src/plugins/python/pythonrunconfiguration.cpp index 3c8c600b0aa..d01f4bc9bb7 100644 --- a/src/plugins/python/pythonrunconfiguration.cpp +++ b/src/plugins/python/pythonrunconfiguration.cpp @@ -16,13 +16,17 @@ #include #include +#include + #include #include #include #include #include +#include #include +#include #include #include @@ -183,10 +187,34 @@ public: // Factories -PythonRunConfigurationFactory::PythonRunConfigurationFactory() +class PythonRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory { - registerRunConfiguration(Constants::C_PYTHONRUNCONFIGURATION_ID); - addSupportedProjectType(PythonProjectId); +public: + PythonRunConfigurationFactory() + { + registerRunConfiguration(Constants::C_PYTHONRUNCONFIGURATION_ID); + addSupportedProjectType(PythonProjectId); + } +}; + +void setupPythonRunConfiguration() +{ + static PythonRunConfigurationFactory thePythonRunConfigurationFactory; +} + +void setupPythonRunWorker() +{ + static SimpleTargetRunnerFactory thePythonRunWorkerFactory( + {Constants::C_PYTHONRUNCONFIGURATION_ID} + ); +} + +void setupPythonDebugWorker() +{ + static Debugger::SimpleDebugRunnerFactory thePythonDebugRunWorkerFactory( + {Constants::C_PYTHONRUNCONFIGURATION_ID}, + {ProjectExplorer::Constants::DAP_PY_DEBUG_RUN_MODE} + ); } void setupPythonOutputParser() diff --git a/src/plugins/python/pythonrunconfiguration.h b/src/plugins/python/pythonrunconfiguration.h index db5fe71cc03..a2ccaeffc51 100644 --- a/src/plugins/python/pythonrunconfiguration.h +++ b/src/plugins/python/pythonrunconfiguration.h @@ -3,20 +3,11 @@ #pragma once -#include -#include -#include - namespace Python::Internal { -class PySideUicExtraCompiler; - -class PythonRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory -{ -public: - PythonRunConfigurationFactory(); -}; - +void setupPythonRunConfiguration(); +void setupPythonRunWorker(); +void setupPythonDebugWorker(); void setupPythonOutputParser(); } // Python::Internal