summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-12-17 18:18:10 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-12-17 18:18:10 +0000
commit890767c0b95d5b6060cdb1dd0a4ed52d8bf4ad5d (patch)
treee365935335aec5197df91b8d8c141038a8c2fb81
parent547347d03618c90faff163f80f6520160f7c3741 (diff)
- fix for the possible endless loop scanning menus;
- code optimization git-svn-id: http://svn.miranda-ng.org/main/trunk@15887 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--src/mir_app/src/menu_utils.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/mir_app/src/menu_utils.cpp b/src/mir_app/src/menu_utils.cpp
index 6ef5d6d9cf..7b18c645ac 100644
--- a/src/mir_app/src/menu_utils.cpp
+++ b/src/mir_app/src/menu_utils.cpp
@@ -575,11 +575,6 @@ static int FreeMenuItem(TMO_IntMenuItem* pimi, void*)
return FALSE;
}
-static int FindParent(TMO_IntMenuItem* pimi, void* p)
-{
- return pimi->next == p;
-}
-
MIR_APP_DLL(int) Menu_RemoveItem(HGENMENU hMenuItem)
{
mir_cslock lck(csMenuHook);
@@ -592,14 +587,7 @@ MIR_APP_DLL(int) Menu_RemoveItem(HGENMENU hMenuItem)
pimi->submenu.first = NULL;
}
- TMO_IntMenuItem *prev = MO_RecursiveWalkMenu(pimi->owner->first, FindParent, pimi);
- if (prev)
- prev->next = pimi->next;
- if (pimi->owner->first == pimi)
- pimi->owner->first = pimi->next;
- if (pimi->owner->last == pimi)
- pimi->owner->last = prev;
-
+ pimi->owner->remove(pimi);
pimi->signature = 0; // invalidate all future calls to that object
pimi->parent->freeItem(pimi);
return 0;
@@ -1040,9 +1028,13 @@ int Menu_LoadFromDatabase(TMO_IntMenuItem *pimi, void *szModule)
if (p == NULL)
return NULL;
+ pimi->mi.root = p;
pNew = &p->submenu;
}
- else pNew = &pmo->m_items;
+ else {
+ pimi->mi.root = NULL;
+ pNew = &pmo->m_items;
+ }
// relink menu item
pimi->owner->remove(pimi);