Improve handleDestroyedAction

--crash on restart
This commit is contained in:
Martin Gräßlin 2013-07-16 18:13:49 +02:00
parent 5b3529acf8
commit 19c5a06fe9

View file

@ -111,14 +111,17 @@ template <typename T>
void handleDestroyedAction(QObject *object, T &shortcuts) void handleDestroyedAction(QObject *object, T &shortcuts)
{ {
for (auto it = shortcuts.begin(); it != shortcuts.end(); ++it) { for (auto it = shortcuts.begin(); it != shortcuts.end(); ++it) {
auto list = (*it); auto &list = it.value();
for (auto it2 = list.begin(); it2 != list.end(); ++it2) { auto it2 = list.begin();
if (InternalGlobalShortcut *shortcut = dynamic_cast<InternalGlobalShortcut*>((*it2))) { while (it2 != list.end()) {
if (InternalGlobalShortcut *shortcut = dynamic_cast<InternalGlobalShortcut*>(it2.value())) {
if (shortcut->action() == object) { if (shortcut->action() == object) {
delete *it2;
it2 = list.erase(it2); it2 = list.erase(it2);
delete shortcut;
continue;
} }
} }
++it2;
} }
} }
} }