From 7b27f200b1f131f0ea3b23433974cbe68eb979bb Mon Sep 17 00:00:00 2001 From: flow Date: Fri, 5 Aug 2022 16:23:46 -0300 Subject: [PATCH] fix: don't mutate QHash while iterating over it Even though it was using a QMutableHashIterator, sometimes it didn't work quite well, so this is a bit better. Signed-off-by: flow --- launcher/modplatform/EnsureMetadataTask.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/launcher/modplatform/EnsureMetadataTask.cpp b/launcher/modplatform/EnsureMetadataTask.cpp index 11bdb99d..42137398 100644 --- a/launcher/modplatform/EnsureMetadataTask.cpp +++ b/launcher/modplatform/EnsureMetadataTask.cpp @@ -119,11 +119,9 @@ void EnsureMetadataTask::executeTask() } auto invalidade_leftover = [this] { - QMutableHashIterator mods_iter(m_mods); - while (mods_iter.hasNext()) { - auto mod = mods_iter.next(); - emitFail(mod.value(), mod.key()); - } + for (auto mod = m_mods.constBegin(); mod != m_mods.constEnd(); mod++) + emitFail(mod.value(), mod.key(), RemoveFromList::No); + m_mods.clear(); emitSucceeded(); };