Hi,

When opening a file in WinWord98 the latter sometimes crashes.

Apparently, one window (probably the top filedialog window?) gets destroyed
and following sequence of events happens:

WIN_SendDestroyMsg() is entered for the toplevel window
focus is set
WM_DESTROY is sent to the window

for all children:
        WIN_SendDestroyMsg() is entered for the child window

        WM_DESTROY is sent to the child window
        ...
        focus is set to the PARENT (toplevel destroyed) window.

focus is set to the PARENT window.

Apparently WinWord does not like this, and dumps on the child SETFOCUS call
to the toplevel destroyed window.

(I think it removes it internal data structures on WM_DESTROY and gets
 very confused as it gets WM_SETFOCUS to it later.)

Relevant part of backtrace:

=>0 0x3099e941 (MSO97.DLL.?OnContextHelp@CSdmDlg@@QAEHI@Z+0x2284) (ebp=2b2d33c8)
  1 0x2afebf83 (WINPROC_wrapper+0x17) (ebp=2b2d33ec)
  2 0x2afec014 (WINPROC_CallWndProc+0x88(proc=0x3082398e, hwnd=0x135c, msg=0x7, 
wParam=0x13e8, lParam=0x0) [winproc.c:170]) (ebp=2b2d342c)
  3 0x2aff0e45 (WINPROC_CallProc16To32A+0x55(func=0x3082398e, hwnd=0x135c, msg=0x7, 
wParam=0x13e8, lParam=0x0) [winproc.c:2315]) (ebp=2b2d346c)
  4 0x2aff1132 (CallWindowProc16+0xc6(func=0x2b750eec, hwnd=0x135c, msg=0x7, 
wParam=0x13e8, lParam=0x0) [winproc.c:2436]) (ebp=2b2d34ac)
  5 0x2afcda91 (MSG_SendMessage+0x401(hwnd=0x135c, msg=0x7, wParam=0x13e8, lParam=0x0, 
timeout=0xffffffff, flags=0x0, pRes=0x2b2d3538) [message.c:1800]) (ebp=2b2d34fc)
  6 0x2afcdb11 (SendMessage16+0x35(hwnd=0x135c, msg=0x7, wParam=0x13e8, lParam=0x0) 
[message.c:1823]) (ebp=2b2d353c)
  7 0x2afc1c34 (FOCUS_SwitchFocus+0xa4(pMsgQ=0x2ae1909c, hFocusFrom=0x13e8, 
hFocusTo=0x135c) [focus.c:59]) (ebp=2b2d356c)
  8 0x2afc1e68 (SetFocus+0x200(hwnd=0x135c) [focus.c:159]) (ebp=2b2d35bc)
  9 0x2afc1c5c (SetFocus16+0x20(hwnd=0x135c) [focus.c:67]) (ebp=2b2d35ec)
  10 0x2afe3b68 (WIN_CheckFocus+0x44(pWnd=0x2ae037e8) [win.c:1225]) (ebp=2b2d361c)
  11 0x2afe3b91 (WIN_SendDestroyMsg+0x21(pWnd=0x2ae037e8, refocus=0x0) [win.c:1234]) 
(ebp=2b2d365c)
  12 0x2afe3cb4 (WIN_SendDestroyMsg+0x144(pWnd=0x2ae0375c, refocus=0x1) [win.c:1308]) 
(ebp=2b2d369c)
  13 0x2afe3f71 (DestroyWindow+0x225(hwnd=0x135c) [win.c:1435]) (ebp=2b2d36cc)

The following patch cures the problem, but I do not know if it is correct.
Someone please approve it :)

Ciao, Marcus

Changelog:
        dont call WM_SETFOCUS in known-destroyed windows.

Index: windows/win.c
===================================================================
RCS file: /home/wine/wine/windows/win.c,v
retrieving revision 1.103
diff -u -r1.103 win.c
--- win.c       2000/10/13 17:07:08     1.103
+++ win.c       2000/10/22 19:09:53
@@ -1228,9 +1228,10 @@
 /***********************************************************************
  *           WIN_SendDestroyMsg
  */
-static void WIN_SendDestroyMsg( WND* pWnd )
+static void WIN_SendDestroyMsg( WND* pWnd, BOOL refocus )
 {
-    WIN_CheckFocus(pWnd);
+    if (refocus)
+       WIN_CheckFocus(pWnd);
 
     if( CARET_GetHwnd() == pWnd->hwndSelf ) DestroyCaret();
     USER_Driver.pResetSelectionOwner( pWnd, TRUE ); 
@@ -1303,7 +1304,7 @@
 
        if (pChild!=NULL)
        {
-         WIN_SendDestroyMsg( pChild );
+         WIN_SendDestroyMsg( pChild , FALSE );
          WIN_ReleaseWndPtr(pChild);      
        }
       }
@@ -1312,7 +1313,8 @@
        * Cleanup
        */
       HeapFree(GetProcessHeap(), 0, pWndArray);
-      WIN_CheckFocus(pWnd);    
+      if (refocus)
+        WIN_CheckFocus(pWnd);  
     }
     else
       WARN("\tdestroyed itself while in WM_DESTROY!\n");
@@ -1429,7 +1431,7 @@
 
       /* Send destroy messages */
 
-    WIN_SendDestroyMsg( wndPtr );
+    WIN_SendDestroyMsg( wndPtr, TRUE );
     if (!IsWindow(hwnd))
     {
         retvalue = TRUE;


Reply via email to