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

Alexandre Julliard julliard at winehq.org
Wed Aug 12 11:09:04 CDT 2009


Module: wine
Branch: master
Commit: 06b99c62c20f1ddb2cc739e1790baf67dd71294b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=06b99c62c20f1ddb2cc739e1790baf67dd71294b

Author: Rein Klazes <wijn at online.nl>
Date:   Wed Aug 12 07:11:04 2009 +0200

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

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 5299c60..90a6e5a 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -4646,18 +4646,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;
 }
 
 




More information about the wine-cvs mailing list