From 55b5b8a975eb806594d1d0357293f40c27f01c06 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 23 Aug 2023 10:16:28 +0200 Subject: [PATCH] CMakeProjectManager: Fix connection to save tools settings Amends 4e23f2a6eb52. This should actually not be needed in the end, and rather steered by the auto registration and settings page apply. Change-Id: I7f94e776fec4394f539e32e5c527c367251654a8 Reviewed-by: Christian Stenger Reviewed-by: --- .../cmakeprojectmanager/cmakekitaspect.cpp | 33 +++++++++++++++---- .../cmakeprojectmanager/cmakekitaspect.h | 4 +++ .../cmakeprojectplugin.cpp | 3 +- .../cmakeprojectmanager/cmaketoolmanager.cpp | 3 ++ 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakekitaspect.cpp b/src/plugins/cmakeprojectmanager/cmakekitaspect.cpp index f2dbb7c9749..b3c4826ef2c 100644 --- a/src/plugins/cmakeprojectmanager/cmakekitaspect.cpp +++ b/src/plugins/cmakeprojectmanager/cmakekitaspect.cpp @@ -1283,23 +1283,44 @@ KitAspect *CMakeConfigurationKitAspectFactory::createKitAspect(Kit *k) const // Factory instances; -const CMakeKitAspectFactory theCMakeKitAspectFactory; -const CMakeGeneratorKitAspectFactory theCMakeGeneratorKitAspectFactory; -const CMakeConfigurationKitAspectFactory theCMakeConfigurationKitAspectFactory; +CMakeKitAspectFactory &cmakeKitAspectFactory() +{ + static CMakeKitAspectFactory theCMakeKitAspectFactory; + return theCMakeKitAspectFactory; +} + +CMakeGeneratorKitAspectFactory &cmakeGeneratorKitAspectFactory() +{ + static CMakeGeneratorKitAspectFactory theCMakeGeneratorKitAspectFactory; + return theCMakeGeneratorKitAspectFactory; +} + +static CMakeConfigurationKitAspectFactory &cmakeConfigurationKitAspectFactory() +{ + static CMakeConfigurationKitAspectFactory theCMakeConfigurationKitAspectFactory; + return theCMakeConfigurationKitAspectFactory; +} KitAspect *CMakeKitAspect::createKitAspect(Kit *k) { - return theCMakeKitAspectFactory.createKitAspect(k); + return cmakeKitAspectFactory().createKitAspect(k); } KitAspect *CMakeGeneratorKitAspect::createKitAspect(Kit *k) { - return theCMakeGeneratorKitAspectFactory.createKitAspect(k); + return cmakeGeneratorKitAspectFactory().createKitAspect(k); } KitAspect *CMakeConfigurationKitAspect::createKitAspect(Kit *k) { - return theCMakeConfigurationKitAspectFactory.createKitAspect(k); + return cmakeConfigurationKitAspectFactory().createKitAspect(k); +} + +void CMakeKitAspect::createFactories() +{ + cmakeKitAspectFactory(); + cmakeGeneratorKitAspectFactory(); + cmakeConfigurationKitAspectFactory(); } } // namespace CMakeProjectManager diff --git a/src/plugins/cmakeprojectmanager/cmakekitaspect.h b/src/plugins/cmakeprojectmanager/cmakekitaspect.h index bd421f4fb88..9b7f93e23b2 100644 --- a/src/plugins/cmakeprojectmanager/cmakekitaspect.h +++ b/src/plugins/cmakeprojectmanager/cmakekitaspect.h @@ -24,6 +24,10 @@ public: static QString msgUnsupportedVersion(const QByteArray &versionString); static ProjectExplorer::KitAspect *createKitAspect(ProjectExplorer::Kit *k); + +private: + friend class CMakeToolManager; + static void createFactories(); }; class CMAKE_EXPORT CMakeGeneratorKitAspect diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp index 8d0d2f720c1..811d2c0e4b3 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp @@ -43,7 +43,8 @@ namespace CMakeProjectManager::Internal { class CMakeProjectPluginPrivate : public QObject { public: - CMakeToolManager cmakeToolManager; // have that before the first CMakeKitAspect + // This can't be stand-alone yet as it registers in the plugin object pool + CMakeToolManager cmakeToolManager; ParameterAction buildTargetContextAction{ Tr::tr("Build"), diff --git a/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp index 08348a548a2..b5dd3601b0c 100644 --- a/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp @@ -3,6 +3,7 @@ #include "cmaketoolmanager.h" +#include "cmakekitaspect.h" #include "cmakeprojectmanagertr.h" #include "cmakespecificsettings.h" #include "cmaketoolsettingsaccessor.h" @@ -49,6 +50,8 @@ CMakeToolManager::CMakeToolManager() setObjectName("CMakeToolManager"); ExtensionSystem::PluginManager::addObject(this); + + CMakeKitAspect::createFactories(); } CMakeToolManager::~CMakeToolManager()