DestroyMenu doesn't remove the link between window and menu undersome conditions...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  Hi.

  I'm investigating the patches someone has provided to allow the use of
the NevewinterNight Aurora Toolset under linux. I'm trying to find the
correct way to fix the known issues.

  This one is related to the way Aurora creates the menubar. It seems
that it does the following sequence:

// first it creates all the menus for the taskbar (and it fills them)
trace:menu:CreateMenu return 0x2e4
trace:menu:CreateMenu return 0x320
trace:menu:CreateMenu return 0x35c
trace:menu:CreateMenu return 0x398
trace:menu:CreateMenu return 0x3d4
trace:menu:CreateMenu return 0x410
trace:menu:CreateMenu return 0x44c
trace:menu:CreateMenu return 0x488

// then it checks to see if the window already has a menu
trace:menu:GetMenu for 0x30025 returning (nil)

// and then it links the menu to the window
trace:menu:SetMenu (0x30025, 0x2e4);

// after a while, it destroys the menu
trace:menu:DestroyMenu (0x2e4)

// creates a new menu which will get the same handle as the old one
trace:menu:CreateMenu return 0x2e4

// but it does not link the new menu back to the window,
// so the new menu has a null hWnd
trace:menu:GetMenu for 0x30025 returning 0x2e4
trace:menu:GetMenu pmenu 0x30025 connected to hWnd 0x2e4 has null hWnd

  (the last one is a message I added while investigating the problem)

  It seems that the problem lies in the DestroyMenu. Its codepath for
the not null hWnd handle contemplates only the case of a window that
should be destroyed along with the menu itself. It seems that if the
hWnd is not null and the window will survive the destruction of the
menu, it should forget the handle of the destroyed menu.

  the proposed fix seems to work correctly, and now the Aurora menu is
working. I think it should be safe to use.

  later,

/pietrobo


License: LGPL, X11
Changelog:
         Marco Pietrobono <pietrobo@pietrobo.com>
         - force the window linked to a popup menu to forget about the
           menu when the menu is destroyed.

-- 
Stud. Marco Pietrobono            | Murphy's Law: if something could
v. del Calice, 39 - 00178 ROMA    |     go wrong, it does.
Tel. +39.06.7186329  339.7410893  | Legge di Murphy: se qualcosa pu?
http://www.pietrobo.com           |    andar male, lo far?.
------------------------------------------------------------------------
A strange game.
The only winning move is
not to play.
What about a nice play of chess ?
Index: controls/menu.c
===================================================================
RCS file: /home/wine/wine/controls/menu.c,v
retrieving revision 1.163
diff -u -r1.163 menu.c
--- controls/menu.c	7 Mar 2003 23:03:27 -0000	1.163
+++ controls/menu.c	6 Apr 2003 20:46:36 -0000
@@ -3645,10 +3645,15 @@
 
         lppop->wMagic = 0;  /* Mark it as destroyed */
 
-        if ((lppop->wFlags & MF_POPUP) && lppop->hWnd)
+        if (lppop->hWnd)
         {
-            DestroyWindow( lppop->hWnd );
-            lppop->hWnd = 0;
+             if ((lppop->wFlags & MF_POPUP))
+             {
+                  DestroyWindow( lppop->hWnd );
+                  lppop->hWnd = 0;
+             }
+	     else
+                 SetWindowLongA( lppop->hWnd, GWL_ID, (LONG_PTR)0 );
         }
 
         if (lppop->items) /* recursively destroy submenus */

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux