From 107dd27063133238f776277bb48853d8a7d07451 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Thu, 27 Oct 2022 11:24:55 +0300 Subject: [PATCH] kded: crash fix for the case when QT_FOREACH_COMPAT is not defined Signed-off-by: Ivailo Monev --- kded/vfolder_menu.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/kded/vfolder_menu.cpp b/kded/vfolder_menu.cpp index c09b18ca..cb1c649f 100644 --- a/kded/vfolder_menu.cpp +++ b/kded/vfolder_menu.cpp @@ -113,12 +113,15 @@ VFolderMenu::includeItems(QHash& items1, const QHash& items1, const QHash& items2) { - foreach (const KService::Ptr &p, items1) - { - QString id = p->menuId(); - if (!items2.contains(id)) - items1.remove(id); - } + QHash::iterator it = items1.begin(); + while (it != items1.end()) { + QString id = (*it)->menuId(); + if (!items2.contains(id)) { + it = items1.erase(it); + } else { + it++; + } + } } void