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.
This commit is contained in:
Rein Klazes 2009-08-12 07:11:04 +02:00 committed by Alexandre Julliard
parent 32e3539413
commit 06b99c62c2
1 changed files with 8 additions and 4 deletions

View File

@ -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;
}