kglobalaccel: use QMutableListIterator<T>() for iteration in Component::loadSettings()

fixes possbile crash

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-10-28 23:30:50 +03:00
parent 982fc92539
commit 09c31e98dc

View file

@ -324,12 +324,14 @@ void Component::loadSettings(KConfigGroup &configGroup)
shortcut->setDefaultKeys(keysFromString(entry[1])); shortcut->setDefaultKeys(keysFromString(entry[1]));
shortcut->setIsFresh(false); shortcut->setIsFresh(false);
Q_FOREACH (int key, keys) { QMutableListIterator<int> keysit(keys);
while (keysit.hasNext()) {
int key = keysit.next();
if (key != 0) { if (key != 0) {
if (GlobalShortcutsRegistry::self()->getShortcutByKey(key)) { if (GlobalShortcutsRegistry::self()->getShortcutByKey(key)) {
// The shortcut is already used. The config file is // The shortcut is already used. The config file is
// broken. Ignore the request. // broken. Ignore the request.
keys.removeAll(key); keysit.remove();
kWarning() << "Shortcut found twice in kglobalshortcutsrc."; kWarning() << "Shortcut found twice in kglobalshortcutsrc.";
} }
} }