windows/win.c messages

Walt Ogburn reuben at
Mon Nov 29 22:44:19 CST 2004

Re-submitting with a proper subject line.  This changes the order of two
things when destroying a windows to avoid calling already-freed functions.

- Walter

In WIN_DestroyWindow, sending a WM_NCDESTROY may cause a window's winprocs
to be freed, but then ReleaseCapture sends a WM_CAPTURECHANGED which can
try to call the just-freed functions.  Do ReleaseCapture first so this is

If that's not acceptable for some reason, an alternative is to add a check
in winproc.c:CallWindowProc to make sure that you don't call something
that's been freed.  Maybe that would be useful in any case.

This fixes several crashes in the Aloha application mentioned by Emanuele
Gissi on wine-users.

- Walter

Call ReleaseCapture before sending WM_NCDESTROY when destroying a window.

Index: windows/win.c
RCS file: /home/wine/wine/windows/win.c,v
retrieving revision 1.250
diff -u -r1.250 win.c
--- windows/win.c       18 Oct 2004 21:25:26 -0000      1.250
+++ windows/win.c       7 Nov 2004 22:26:25 -0000
@@ -622,15 +622,15 @@
     RedrawWindow( hwnd, NULL, 0,

+    WINPOS_CheckInternalPos( hwnd );
+    if( hwnd == GetCapture()) ReleaseCapture();
      * Send the WM_NCDESTROY to the window being destroyed.
     SendMessageA( hwnd, WM_NCDESTROY, 0, 0);

     /* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */
-    WINPOS_CheckInternalPos( hwnd );
-    if( hwnd == GetCapture()) ReleaseCapture();

     /* free resources associated with the window */

More information about the wine-patches mailing list