forked from qt-creator/qt-creator
CMakePM: Traverse the whole inheritance tree for Presets
Regarding QTCREATORBUG-30288, before this change I was getting on macOS presets for Linux and Windows. Fixes: QTCREATORBUG-30236 Fixes: QTCREATORBUG-30288 Change-Id: I4772ab7d14dec857b68164d4c24e6e904f20c88b Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -89,6 +89,21 @@ PresetsData CMakeProject::presetsData() const
|
|||||||
return m_presetsData;
|
return m_presetsData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
static QStringList recursiveInheritsList(const T &presetsHash, const QStringList &inheritsList)
|
||||||
|
{
|
||||||
|
QStringList result;
|
||||||
|
for (const QString &inheritFrom : inheritsList) {
|
||||||
|
result << inheritFrom;
|
||||||
|
if (presetsHash.contains(inheritFrom)) {
|
||||||
|
auto item = presetsHash[inheritFrom];
|
||||||
|
if (item.inherits)
|
||||||
|
result << recursiveInheritsList(presetsHash, item.inherits.value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
Internal::PresetsData CMakeProject::combinePresets(Internal::PresetsData &cmakePresetsData,
|
Internal::PresetsData CMakeProject::combinePresets(Internal::PresetsData &cmakePresetsData,
|
||||||
Internal::PresetsData &cmakeUserPresetsData)
|
Internal::PresetsData &cmakeUserPresetsData)
|
||||||
{
|
{
|
||||||
@@ -135,12 +150,14 @@ Internal::PresetsData CMakeProject::combinePresets(Internal::PresetsData &cmakeP
|
|||||||
if (!p.inherits)
|
if (!p.inherits)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (const QString &inheritFromName : p.inherits.value()) {
|
const QStringList inheritsList = recursiveInheritsList(presetsHash,
|
||||||
if (presetsHash.contains(inheritFromName)) {
|
p.inherits.value());
|
||||||
p.inheritFrom(presetsHash[inheritFromName]);
|
Utils::reverseForeach(inheritsList, [&presetsHash, &p](const QString &inheritFrom) {
|
||||||
|
if (presetsHash.contains(inheritFrom)) {
|
||||||
|
p.inheritFrom(presetsHash[inheritFrom]);
|
||||||
presetsHash[p.name] = p;
|
presetsHash[p.name] = p;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user