From 3fad1a21e5097d57594c06a56b6fa1f5575d1dc8 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 30 Jan 2024 14:33:19 +0100 Subject: [PATCH] CMake: Use a setup function for kit aspects Some connects() in the CMakeToolManager ctor triggered accesses to the s_instance there before it was assigned. Solve the issue by moving the triggering code (CMakeKitAspect setup) out of the class. Change-Id: Ied0fc6b0b0eb87c29503ecb20e337289edecd203 Reviewed-by: Christian Stenger --- src/plugins/cmakeprojectmanager/cmakekitaspect.cpp | 2 +- src/plugins/cmakeprojectmanager/cmakekitaspect.h | 3 ++- src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp | 2 ++ src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp | 6 +++--- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakekitaspect.cpp b/src/plugins/cmakeprojectmanager/cmakekitaspect.cpp index c49ad1ae3c3..00750f4d3c5 100644 --- a/src/plugins/cmakeprojectmanager/cmakekitaspect.cpp +++ b/src/plugins/cmakeprojectmanager/cmakekitaspect.cpp @@ -1279,7 +1279,7 @@ KitAspect *CMakeConfigurationKitAspect::createKitAspect(Kit *k) return cmakeConfigurationKitAspectFactory().createKitAspect(k); } -void CMakeKitAspect::createFactories() +void Internal::setupCMakeKitAspects() { cmakeKitAspectFactory(); cmakeGeneratorKitAspectFactory(); diff --git a/src/plugins/cmakeprojectmanager/cmakekitaspect.h b/src/plugins/cmakeprojectmanager/cmakekitaspect.h index b85bb7bad31..cf734d19576 100644 --- a/src/plugins/cmakeprojectmanager/cmakekitaspect.h +++ b/src/plugins/cmakeprojectmanager/cmakekitaspect.h @@ -27,7 +27,6 @@ public: private: friend class CMakeToolManager; - static void createFactories(); }; class CMAKE_EXPORT CMakeGeneratorKitAspect @@ -70,4 +69,6 @@ public: static ProjectExplorer::KitAspect *createKitAspect(ProjectExplorer::Kit *k); }; +namespace Internal { void setupCMakeKitAspects(); } + } // CMakeProjectManager diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp index d9b840a7729..9c2a23dc061 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp @@ -8,6 +8,7 @@ #include "cmakeformatter.h" #include "cmakeinstallstep.h" #include "cmakelocatorfilter.h" +#include "cmakekitaspect.h" #include "cmakeparser.h" #include "cmakeproject.h" #include "cmakeprojectconstants.h" @@ -53,6 +54,7 @@ class CMakeProjectPlugin final : public ExtensionSystem::IPlugin setupCMakeToolManager(this); setupCMakeSettingsPage(); + setupCMakeKitAspects(); setupCMakeBuildConfiguration(); setupCMakeBuildStep(); diff --git a/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp index b6caf2a7f4e..cf63ce791f5 100644 --- a/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp @@ -18,13 +18,15 @@ #include #include #include -#include + #include #include #include #include +#include + using namespace Core; using namespace Utils; @@ -186,8 +188,6 @@ CMakeToolManager::CMakeToolManager() setObjectName("CMakeToolManager"); ExtensionSystem::PluginManager::addObject(this); - - CMakeKitAspect::createFactories(); } CMakeToolManager::~CMakeToolManager()