ProjectExplorer: Fix unsafe kit removal procedure

We iterated through a list that was in the middle of a std::remove(),
which is not safe.

Change-Id: I2b4bce18ebe3365fd22f33521aa82868c10e9647
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2021-10-07 14:47:46 +02:00
parent 0b96a1b76b
commit 5156c8b510

View File

@@ -238,12 +238,15 @@ void KitManager::restoreKits()
kitsToCheck.clear(); kitsToCheck.clear();
// Remove replacement kits for which the original kit has turned up again. // Remove replacement kits for which the original kit has turned up again.
Utils::erase(resultList, [&resultList](const std::unique_ptr<Kit> &k) { for (auto it = resultList.begin(); it != resultList.end();) {
return k->isReplacementKit() const auto &k = *it;
&& contains(resultList, [&k](const std::unique_ptr<Kit> &other) { if (k->isReplacementKit() && contains(resultList, [&k](const std::unique_ptr<Kit> &other) {
return other->id() == k->id() && other != k; return other->id() == k->id() && other != k; })) {
}); it = resultList.erase(it);
}); } else {
++it;
}
}
static const auto kitMatchesAbiList = [](const Kit *kit, const Abis &abis) { static const auto kitMatchesAbiList = [](const Kit *kit, const Abis &abis) {
const QList<ToolChain *> toolchains = ToolChainKitAspect::toolChains(kit); const QList<ToolChain *> toolchains = ToolChainKitAspect::toolChains(kit);