From 5156c8b510cedc888d5b489d52ef18f098979543 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 7 Oct 2021 14:47:46 +0200 Subject: 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 --- src/plugins/projectexplorer/kitmanager.cpp | 15 +++++++++------ 1 file 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 &k) { - return k->isReplacementKit() - && contains(resultList, [&k](const std::unique_ptr &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 &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 toolchains = ToolChainKitAspect::toolChains(kit); -- cgit v1.2.3