From 1e4d8ff6ce3402351504a0f291de464bb4db6ccf Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Wed, 2 Oct 2024 15:42:15 +0200 Subject: [PATCH] CMakeProjectManager: Allow "none" value in CMakeKitAspect For consistency with the other "tool-like" aspects. Task-number: QTCREATORBUG-31574 Change-Id: I71e5e51b91e06cedc4c63e2473d6c58364785979 Reviewed-by: hjk Reviewed-by: Cristian Adam --- .../cmakeprojectmanager/cmakekitaspect.cpp | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakekitaspect.cpp b/src/plugins/cmakeprojectmanager/cmakekitaspect.cpp index 4461d3e133e..a827190d185 100644 --- a/src/plugins/cmakeprojectmanager/cmakekitaspect.cpp +++ b/src/plugins/cmakeprojectmanager/cmakekitaspect.cpp @@ -84,9 +84,7 @@ public: }); for (CMakeTool *item : toolsForBuildDevice) rootItem()->appendChild(new CMakeToolTreeItem(item, false)); - - // TODO: The aspect actively prevents the "no value" case in several places - // rootItem()->appendChild(new CMakeToolTreeItem); + rootItem()->appendChild(new CMakeToolTreeItem); // The "none" item. } private: @@ -241,10 +239,7 @@ private: return i; } - // TODO: Enable once we have "none" entry. - // return m_comboBox->count() - 1; - - return -1; + return m_comboBox->count() - 1; } void currentCMakeToolChanged(int index) @@ -306,10 +301,9 @@ CMakeTool *CMakeKitAspect::cmakeTool(const Kit *k) void CMakeKitAspect::setCMakeTool(Kit *k, const Id id) { - const Id toSet = id.isValid() ? id : defaultCMakeToolId(); - QTC_ASSERT(!id.isValid() || CMakeToolManager::findById(toSet), return); + QTC_ASSERT(!id.isValid() || CMakeToolManager::findById(id), return); if (k) - k->setValue(Constants::TOOL_ID, toSet.toSetting()); + k->setValue(Constants::TOOL_ID, id.toSetting()); } Tasks CMakeKitAspectFactory::validate(const Kit *k) const @@ -347,7 +341,11 @@ void CMakeKitAspectFactory::setup(Kit *k) void CMakeKitAspectFactory::fix(Kit *k) { - setup(k); + // TODO: Differentiate (centrally?) between "nothing set" and "actively set to nothing". + if (const Id id = CMakeKitAspect::cmakeToolId(k); + id.isValid() && !CMakeToolManager::findById(id)) { + setup(k); + } } KitAspectFactory::ItemList CMakeKitAspectFactory::toUserOutput(const Kit *k) const