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 <christian.stenger@qt.io>
This commit is contained in:
hjk
2024-01-30 14:33:19 +01:00
parent 2f13651344
commit 3fad1a21e5
4 changed files with 8 additions and 5 deletions

View File

@@ -1279,7 +1279,7 @@ KitAspect *CMakeConfigurationKitAspect::createKitAspect(Kit *k)
return cmakeConfigurationKitAspectFactory().createKitAspect(k);
}
void CMakeKitAspect::createFactories()
void Internal::setupCMakeKitAspects()
{
cmakeKitAspectFactory();
cmakeGeneratorKitAspectFactory();

View File

@@ -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

View File

@@ -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();

View File

@@ -18,13 +18,15 @@
#include <projectexplorer/buildsystem.h>
#include <projectexplorer/projecttree.h>
#include <projectexplorer/target.h>
#include <stack>
#include <utils/environment.h>
#include <utils/pointeralgorithm.h>
#include <utils/qtcassert.h>
#include <nanotrace/nanotrace.h>
#include <stack>
using namespace Core;
using namespace Utils;
@@ -186,8 +188,6 @@ CMakeToolManager::CMakeToolManager()
setObjectName("CMakeToolManager");
ExtensionSystem::PluginManager::addObject(this);
CMakeKitAspect::createFactories();
}
CMakeToolManager::~CMakeToolManager()