diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2021-10-07 14:47:46 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2021-10-07 15:21:16 +0000 |
commit | 5156c8b510cedc888d5b489d52ef18f098979543 (patch) | |
tree | d1b5e554d53a0bdb8b44b411e16eebbeeb17bdcd | |
parent | 0b96a1b76b869d8227e10ec1dd6aa9c21ba5ff13 (diff) |
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>
-rw-r--r-- | src/plugins/projectexplorer/kitmanager.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/plugins/projectexplorer/kitmanager.cpp b/src/plugins/projectexplorer/kitmanager.cpp index 3f77fee414..1c338d730a 100644 --- a/src/plugins/projectexplorer/kitmanager.cpp +++ b/src/plugins/projectexplorer/kitmanager.cpp @@ -238,12 +238,15 @@ void KitManager::restoreKits() kitsToCheck.clear(); // Remove replacement kits for which the original kit has turned up again. - Utils::erase(resultList, [&resultList](const std::unique_ptr<Kit> &k) { - return k->isReplacementKit() - && contains(resultList, [&k](const std::unique_ptr<Kit> &other) { - return other->id() == k->id() && other != k; - }); - }); + for (auto it = resultList.begin(); it != resultList.end();) { + const auto &k = *it; + if (k->isReplacementKit() && contains(resultList, [&k](const std::unique_ptr<Kit> &other) { + return other->id() == k->id() && other != k; })) { + it = resultList.erase(it); + } else { + ++it; + } + } static const auto kitMatchesAbiList = [](const Kit *kit, const Abis &abis) { const QList<ToolChain *> toolchains = ToolChainKitAspect::toolChains(kit); |