DestroyMenu: Check if the menu is still used (fix for bug 1486)

Michael Kaufmann hallo at michael-kaufmann.ch
Mon Sep 6 04:58:40 CDT 2004


Hi Dmitry

>There is a test case in Wine (dlls/user/tests/win.c,test_SetMenu) which shows
>that your patch is wrong.
>  
>

This test case also fails on Win9x, as you can see in the code of the 
test case:

ok(DestroyMenu(hMenu), "DestroyMenu error %ld\n", GetLastError());
ok(!IsMenu(hMenu), "menu handle should be not valid after DestroyMenu\n");
ret = GetMenu(parent);
/* This test fails on Win9x */
if (!is_win9x)
    ok(ret == hMenu, "unexpected menu id %p\n", ret);


It doesn't make sense to me to check that the menu handle is invalid AND 
it is still assigned to the window. Windows 2000 only passes this test 
because it keeps using the menu. It destroys the menu when it's not 
needed anymore. WINE is not so clever (yet), therefore we have to do it 
the same way as Windows 9x.

I think we should modify this testcase. After all, the behavior of 
DestroyMenu in this situation is undocumented.

I've searched for other patches on this subject. I was very surprised to 
see that Andreas Mohr submitted a patch for the same problem about two 
years ago:

http://www.winehq.com/hypermail/wine-patches/2002/08/0124.html
http://www.winehq.com/hypermail/wine-patches/2002/09/0039.html

He describes the problem very well. It seems that his patch was not 
checked in, or it has been modified since.
My patch doesn't have the problem that he describes in the second post.


>It was said many times already that the real fix for that bug is to move
>all user object management into wineserver and use the same handle allocation
>scheme as the one used for windows.
>  
>

Sorry, I'm new to WINE development and don't know this discussion. Maybe 
you can provide a link?

However, I don't think that this will fix the problem. I'm sure that my 
patch won't break existing applications, and it's very important for 
many Delphi applications, because Delphi often calls DestroyMenu on 
active menus.

Regards

Michael



More information about the wine-devel mailing list