CMakeProjectManager: Allow "none" value in CMakeKitAspect

For consistency with the other "tool-like" aspects.

Task-number: QTCREATORBUG-31574
Change-Id: I71e5e51b91e06cedc4c63e2473d6c58364785979
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Christian Kandeler
2024-10-02 15:42:15 +02:00
parent 8a4a33c177
commit 1e4d8ff6ce

View File

@@ -84,9 +84,7 @@ public:
}); });
for (CMakeTool *item : toolsForBuildDevice) for (CMakeTool *item : toolsForBuildDevice)
rootItem()->appendChild(new CMakeToolTreeItem(item, false)); rootItem()->appendChild(new CMakeToolTreeItem(item, false));
rootItem()->appendChild(new CMakeToolTreeItem); // The "none" item.
// TODO: The aspect actively prevents the "no value" case in several places
// rootItem()->appendChild(new CMakeToolTreeItem);
} }
private: private:
@@ -241,10 +239,7 @@ private:
return i; return i;
} }
// TODO: Enable once we have "none" entry. return m_comboBox->count() - 1;
// return m_comboBox->count() - 1;
return -1;
} }
void currentCMakeToolChanged(int index) void currentCMakeToolChanged(int index)
@@ -306,10 +301,9 @@ CMakeTool *CMakeKitAspect::cmakeTool(const Kit *k)
void CMakeKitAspect::setCMakeTool(Kit *k, const Id id) void CMakeKitAspect::setCMakeTool(Kit *k, const Id id)
{ {
const Id toSet = id.isValid() ? id : defaultCMakeToolId(); QTC_ASSERT(!id.isValid() || CMakeToolManager::findById(id), return);
QTC_ASSERT(!id.isValid() || CMakeToolManager::findById(toSet), return);
if (k) if (k)
k->setValue(Constants::TOOL_ID, toSet.toSetting()); k->setValue(Constants::TOOL_ID, id.toSetting());
} }
Tasks CMakeKitAspectFactory::validate(const Kit *k) const Tasks CMakeKitAspectFactory::validate(const Kit *k) const
@@ -347,8 +341,12 @@ void CMakeKitAspectFactory::setup(Kit *k)
void CMakeKitAspectFactory::fix(Kit *k) void CMakeKitAspectFactory::fix(Kit *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); setup(k);
} }
}
KitAspectFactory::ItemList CMakeKitAspectFactory::toUserOutput(const Kit *k) const KitAspectFactory::ItemList CMakeKitAspectFactory::toUserOutput(const Kit *k) const
{ {