From 19c5a06fe9bca19361d46a72bb39d0e671fb47aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 16 Jul 2013 18:13:49 +0200 Subject: [PATCH] Improve handleDestroyedAction --crash on restart --- globalshortcuts.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/globalshortcuts.cpp b/globalshortcuts.cpp index b7c6585b1e..cdaf53a6d2 100644 --- a/globalshortcuts.cpp +++ b/globalshortcuts.cpp @@ -111,14 +111,17 @@ template void handleDestroyedAction(QObject *object, T &shortcuts) { for (auto it = shortcuts.begin(); it != shortcuts.end(); ++it) { - auto list = (*it); - for (auto it2 = list.begin(); it2 != list.end(); ++it2) { - if (InternalGlobalShortcut *shortcut = dynamic_cast((*it2))) { + auto &list = it.value(); + auto it2 = list.begin(); + while (it2 != list.end()) { + if (InternalGlobalShortcut *shortcut = dynamic_cast(it2.value())) { if (shortcut->action() == object) { - delete *it2; it2 = list.erase(it2); + delete shortcut; + continue; } } + ++it2; } } }