From 3526d38be80fa2083aa24345c0e47a9e59b996c3 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 18 Jan 2024 14:23:16 +0100 Subject: [PATCH] ProjectExplorer: Use setup function for CustomToolChain Change-Id: I05eeaad0914285c31928e9fad126b27ad78a0fa6 Reviewed-by: Jarek Kobus --- .../projectexplorer/customtoolchain.cpp | 24 ++++++++++++------- src/plugins/projectexplorer/customtoolchain.h | 8 +------ .../projectexplorer/projectexplorer.cpp | 3 +-- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/plugins/projectexplorer/customtoolchain.cpp b/src/plugins/projectexplorer/customtoolchain.cpp index fa3de6feab4..c38efd5466f 100644 --- a/src/plugins/projectexplorer/customtoolchain.cpp +++ b/src/plugins/projectexplorer/customtoolchain.cpp @@ -13,6 +13,7 @@ #include "projectexplorerconstants.h" #include "projectexplorertr.h" #include "projectmacro.h" +#include "toolchain.h" #include "toolchainconfigwidget.h" #include @@ -555,17 +556,24 @@ std::unique_ptr CustomToolChain::createConfigurationWidge return std::make_unique(this); } -// -------------------------------------------------------------------------- // CustomToolChainFactory -// -------------------------------------------------------------------------- -CustomToolchainFactory::CustomToolchainFactory() +class CustomToolchainFactory final : public ToolchainFactory { - setDisplayName(Tr::tr("Custom")); - setSupportedToolchainType(Constants::CUSTOM_TOOLCHAIN_TYPEID); - setSupportsAllLanguages(true); - setToolchainConstructor([] { return new CustomToolChain; }); - setUserCreatable(true); +public: + CustomToolchainFactory() + { + setDisplayName(Tr::tr("Custom")); + setSupportedToolchainType(Constants::CUSTOM_TOOLCHAIN_TYPEID); + setSupportsAllLanguages(true); + setToolchainConstructor([] { return new CustomToolChain; }); + setUserCreatable(true); + } +}; + +void setupCustomToolchain() +{ + static CustomToolchainFactory theCustomToolchainFactory; } } // ProjectExplorer::Internal diff --git a/src/plugins/projectexplorer/customtoolchain.h b/src/plugins/projectexplorer/customtoolchain.h index 2263eec5413..8eec7c91160 100644 --- a/src/plugins/projectexplorer/customtoolchain.h +++ b/src/plugins/projectexplorer/customtoolchain.h @@ -3,14 +3,8 @@ #pragma once -#include "toolchain.h" - namespace ProjectExplorer::Internal { -class CustomToolchainFactory : public ToolchainFactory -{ -public: - CustomToolchainFactory(); -}; +void setupCustomToolchain(); } // ProjectExplorer::Interna; diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index db69f4e5b2a..4cf5c55e79d 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -647,8 +647,6 @@ public: WinDebugInterface m_winDebugInterface; #endif - CustomToolchainFactory m_customToolChainFactory; - DesktopDeviceFactory m_desktopDeviceFactory; ToolChainOptionsPage m_toolChainOptionsPage; @@ -818,6 +816,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er setupGccToolchains(); setupMsvcToolchain(); setupClangClToolchain(); + setupCustomToolchain(); setupProjectTreeWidgetFactory();