CMakeProjectManager: Use setup function for CMakeToolManager

Change-Id: I66078250029f87d64b7b31aba9049a8b0b68f3a5
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2024-01-29 14:17:23 +01:00
parent 5f90065ea9
commit cc64c84b5f
3 changed files with 12 additions and 10 deletions

View File

@@ -46,9 +46,6 @@ namespace CMakeProjectManager::Internal {
class CMakeProjectPluginPrivate : public QObject
{
public:
// This can't be stand-alone yet as it registers in the plugin object pool
CMakeToolManager cmakeToolManager;
Action buildTargetContextAction{
Tr::tr("Build"),
Tr::tr("Build \"%1\""),
@@ -79,6 +76,8 @@ class CMakeProjectPlugin final : public ExtensionSystem::IPlugin
void initialize() final
{
setupCMakeToolManager(this);
d = new CMakeProjectPluginPrivate;
setupCMakeManager();

View File

@@ -170,13 +170,10 @@ public:
};
static CMakeToolManagerPrivate *d = nullptr;
CMakeToolManager *CMakeToolManager::m_instance = nullptr;
static CMakeToolManager *m_instance = nullptr;
CMakeToolManager::CMakeToolManager()
{
QTC_ASSERT(!m_instance, return);
m_instance = this;
qRegisterMetaType<QString *>();
d = new CMakeToolManagerPrivate;
@@ -224,7 +221,7 @@ bool CMakeToolManager::registerCMakeTool(std::unique_ptr<CMakeTool> &&tool)
d->m_cmakeTools.emplace_back(std::move(tool));
emit CMakeToolManager::m_instance->cmakeAdded(toolId);
emit m_instance->cmakeAdded(toolId);
ensureDefaultCMakeToolIsValid();
@@ -438,4 +435,10 @@ void CMakeToolManager::ensureDefaultCMakeToolIsValid()
emit m_instance->defaultCMakeChanged();
}
void Internal::setupCMakeToolManager(QObject *guard)
{
m_instance = new CMakeToolManager;
m_instance->setParent(guard);
}
} // CMakeProjectManager

View File

@@ -64,10 +64,10 @@ signals:
private:
static void saveCMakeTools();
static void ensureDefaultCMakeToolIsValid();
static CMakeToolManager *m_instance;
};
namespace Internal { void setupCMakeToolManager(QObject *guard); }
} // namespace CMakeProjectManager
Q_DECLARE_METATYPE(QString *)