diff --git a/src/plugins/python/pythonrunconfiguration.cpp b/src/plugins/python/pythonrunconfiguration.cpp index 6fa59ba06a3..151895449b3 100644 --- a/src/plugins/python/pythonrunconfiguration.cpp +++ b/src/plugins/python/pythonrunconfiguration.cpp @@ -119,26 +119,38 @@ private: //////////////////////////////////////////////////////////////// -class PythonRunConfigurationPrivate +class PythonInterpreterAspect final : public InterpreterAspect { public: - PythonRunConfigurationPrivate(PythonRunConfiguration *rc) + PythonInterpreterAspect(PythonRunConfiguration *rc) : q(rc) - {} - ~PythonRunConfigurationPrivate() + { + connect(this, &InterpreterAspect::changed, + this, &PythonInterpreterAspect::currentInterpreterChanged); + currentInterpreterChanged(); + + connect(PySideInstaller::instance(), &PySideInstaller::pySideInstalled, this, + [this](const FilePath &python) { + if (python == currentInterpreter().command) + checkForPySide(python); + } + ); + } + + ~PythonInterpreterAspect() { qDeleteAll(m_extraCompilers); } - void checkForPySide(const Utils::FilePath &python); - void checkForPySide(const Utils::FilePath &python, const QString &pySidePackageName); + void checkForPySide(const FilePath &python); + void checkForPySide(const FilePath &python, const QString &pySidePackageName); void handlePySidePackageInfo(const PipPackageInfo &pySideInfo, - const Utils::FilePath &python, + const FilePath &python, const QString &requestedPackageName); void updateExtraCompilers(); void currentInterpreterChanged(); - Utils::FilePath m_pySideUicPath; + FilePath m_pySideUicPath; PythonRunConfiguration *q; QList m_extraCompilers; @@ -148,15 +160,11 @@ public: PythonRunConfiguration::PythonRunConfiguration(Target *target, Id id) : RunConfiguration(target, id) - , d(new PythonRunConfigurationPrivate(this)) { - auto interpreterAspect = addAspect(); + auto interpreterAspect = addAspect(this); interpreterAspect->setSettingsKey("PythonEditor.RunConfiguation.Interpreter"); interpreterAspect->setSettingsDialogId(Constants::C_PYTHONOPTIONS_PAGE_ID); - connect(interpreterAspect, &InterpreterAspect::changed, this, - [this] { d->currentInterpreterChanged(); }); - connect(PythonSettings::instance(), &PythonSettings::interpretersChanged, interpreterAspect, &InterpreterAspect::updateInterpreters); @@ -219,27 +227,17 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Id id) }); connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update); - connect(target, &Target::buildSystemUpdated, this, [this]() { d->updateExtraCompilers(); }); - d->currentInterpreterChanged(); - - connect(PySideInstaller::instance(), &PySideInstaller::pySideInstalled, this, - [this](const FilePath &python) { - if (python == aspect()->currentInterpreter().command) - d->checkForPySide(python); - }); + connect(target, &Target::buildSystemUpdated, this, [this, interpreterAspect] { interpreterAspect->updateExtraCompilers(); }); } -PythonRunConfiguration::~PythonRunConfiguration() -{ - delete d; -} +PythonRunConfiguration::~PythonRunConfiguration() = default; -void PythonRunConfigurationPrivate::checkForPySide(const FilePath &python) +void PythonInterpreterAspect::checkForPySide(const FilePath &python) { checkForPySide(python, "PySide6-Essentials"); } -void PythonRunConfigurationPrivate::checkForPySide(const FilePath &python, +void PythonInterpreterAspect::checkForPySide(const FilePath &python, const QString &pySidePackageName) { const PipPackage package(pySidePackageName); @@ -252,7 +250,7 @@ void PythonRunConfigurationPrivate::checkForPySide(const FilePath &python, ExtensionSystem::PluginManager::futureSynchronizer()->addFuture(future); } -void PythonRunConfigurationPrivate::handlePySidePackageInfo(const PipPackageInfo &pySideInfo, +void PythonInterpreterAspect::handlePySidePackageInfo(const PipPackageInfo &pySideInfo, const Utils::FilePath &python, const QString &requestedPackageName) { @@ -308,9 +306,9 @@ void PythonRunConfigurationPrivate::handlePySidePackageInfo(const PipPackageInfo pySideBuildStep->updatePySideProjectPath(pythonTools.pySideProjectPath); } -void PythonRunConfigurationPrivate::currentInterpreterChanged() +void PythonInterpreterAspect::currentInterpreterChanged() { - const FilePath python = q->aspect()->currentInterpreter().command; + const FilePath python = currentInterpreter().command; checkForPySide(python); for (FilePath &file : q->project()->files(Project::AllFiles)) { @@ -326,10 +324,10 @@ void PythonRunConfigurationPrivate::currentInterpreterChanged() QList PythonRunConfiguration::extraCompilers() const { - return d->m_extraCompilers; + return static_cast(aspect())->m_extraCompilers; } -void PythonRunConfigurationPrivate::updateExtraCompilers() +void PythonInterpreterAspect::updateExtraCompilers() { QList oldCompilers = m_extraCompilers; m_extraCompilers.clear(); diff --git a/src/plugins/python/pythonrunconfiguration.h b/src/plugins/python/pythonrunconfiguration.h index 86d174af1a0..81b6a851ce9 100644 --- a/src/plugins/python/pythonrunconfiguration.h +++ b/src/plugins/python/pythonrunconfiguration.h @@ -8,7 +8,6 @@ namespace Python::Internal { -class PythonRunConfigurationPrivate; class PySideUicExtraCompiler; class PythonRunConfiguration : public ProjectExplorer::RunConfiguration @@ -20,9 +19,6 @@ public: ~PythonRunConfiguration() override; QList extraCompilers() const; - -private: - PythonRunConfigurationPrivate *d = nullptr; }; class PythonRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory