Possible bug (with fix) in MENU_FindItem()

Peter Gerwinski peter at gerwinski.de
Wed Jan 8 07:29:46 CST 2003


Hello,

while developing an application for WINE (also intended to run under
MSPOW = MicroSoft's Parody Of WINE, spoken "m-spow";-) I encountered
something which I consider a bug in WINE:

When I invoke EnableMenuItem to enable/disable a menu item holding
a command with the numeric value 200, the first popup menu is
enabled/disabled instead of the menu item. (This behaviour does not
show up under MSPOW, version "ME".)

IMHO this is due to a wrong order of two "if" conditions in
control/menu.c:MENU_FindItem().

I am attaching a patch which fixed the problem for me.

Greetings,

    Peter, wondering why item->wID has a
           value of 200 in the first place
-- 
Software Patents = professional disbarment for programmers
http://swpat.ffii.org
-------------- next part --------------
2003-01-08  Peter Gerwinski  <peter at gerwinski.de>

        * controls/menu.c (MENU_FindItem): Check for MS_POPUP first
        before looking at item->wID (which might be bogus).

--- menu.c.orig	Wed Jan  8 14:08:24 2003
+++ menu.c	Wed Jan  8 14:06:13 2003
@@ -562,12 +562,7 @@
         MENUITEM *item = menu->items;
 	for (i = 0; i < menu->nItems; i++, item++)
 	{
-	    if (item->wID == *nPos)
-	    {
-		*nPos = i;
-		return item;
-	    }
-	    else if (item->fType & MF_POPUP)
+	    if (item->fType & MF_POPUP)
 	    {
 		HMENU hsubmenu = item->hSubMenu;
 		MENUITEM *subitem = MENU_FindItem( &hsubmenu, nPos, wFlags );
@@ -576,6 +571,11 @@
 		    *hmenu = hsubmenu;
 		    return subitem;
 		}
+	    }
+            else if (item->wID == *nPos)
+	    {
+		*nPos = i;
+		return item;
 	    }
 	}
     }


More information about the wine-bugs mailing list