user32: Fix a bug in computing the maximum depth of a branch in a menu hierarchy.

Rein Klazes wijn at online.nl
Wed Aug 12 00:11:04 CDT 2009


Bug: it was computing the number of submenus in the branch, rather then
the maximum depth.
---
 dlls/user32/menu.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index 3b90169..fa47765 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -4660,18 +4660,22 @@ static int MENU_depth( POPUPMENU *pmenu, int depth)
 {
     int i;
     MENUITEM *item;
+    int subdepth;
 
     depth++;
     if( depth > MAXMENUDEPTH) return depth;
     item = pmenu->items;
-    for( i = 0; i < pmenu->nItems && depth <= MAXMENUDEPTH; i++, item++){
-        POPUPMENU *psubmenu =  MENU_GetMenu( item->hSubMenu);
+    subdepth = depth;
+    for( i = 0; i < pmenu->nItems && subdepth <= MAXMENUDEPTH; i++, item++){
+        POPUPMENU *psubmenu =  item->hSubMenu ? MENU_GetMenu( item->hSubMenu) : NULL;
         if( psubmenu){
             int bdepth = MENU_depth( psubmenu, depth);
-            if( bdepth > depth) depth = bdepth;
+            if( bdepth > subdepth) subdepth = bdepth;
         }
+        if( subdepth > MAXMENUDEPTH)
+            TRACE("<- hmenu %p\n", item->hSubMenu);
     }
-    return depth;
+    return subdepth;
 }
 
 
-- 
1.6.3.3




More information about the wine-patches mailing list