From 06b99c62c20f1ddb2cc739e1790baf67dd71294b Mon Sep 17 00:00:00 2001 From: Rein Klazes Date: Wed, 12 Aug 2009 07:11:04 +0200 Subject: [PATCH] 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 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c index 5299c602389..90a6e5ad994 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; }