Ignore:
Timestamp:
Aug 23, 2002, 5:06:01 PM (23 years ago)
Author:
sandervl
Message:

Ugly hack added to work around crash in PM when child window calls DestroyWindow for parent or owner in WM_DESTROY handler (solution: postpone DestroyWindow for parent/owner)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/win32wbase.cpp

    r9001 r9101  
    1 /* $Id: win32wbase.cpp,v 1.335 2002-08-14 10:37:44 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.336 2002-08-23 15:06:01 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    149149  fParentChange    = FALSE;
    150150  fDestroyWindowCalled = FALSE;
     151  fChildDestructionInProgress = FALSE;
    151152  fTaskList        = FALSE;
    152153  fParentDC        = FALSE;
     
    924925
    925926    if(fDestroyWindowCalled == FALSE)
    926     {//this window was destroyed because DestroyWindow was called for it's parent
     927    {//this window was destroyed because DestroyWindow was called for its parent
    927928     //so: send a WM_PARENTNOTIFY now as that hasn't happened yet
    928929        if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
     
    26832684//******************************************************************************
    26842685//Also destroys all the child windows (destroy children first, parent last)
     2686//TODO: Don't rely on PM to do the right thing. Send WM_(NC)DESTROY &
     2687//      destroy children ourselves (see Wine)
    26852688//******************************************************************************
    26862689BOOL Win32BaseWindow::DestroyWindow()
     
    27602763 
    27612764    fDestroyWindowCalled = TRUE;
    2762     return OSLibWinDestroyWindow(OS2HwndFrame);
     2765
     2766//hack alert; PM crashes if child calls DestroyWindow for parent/owner in WM_DESTROY
     2767//            handler; must postpone it
     2768    if(fChildDestructionInProgress) {
     2769        dprintf(("Postponing parent destruction because of dying child"));
     2770        OSLibPostMessageDirect(OS2HwndFrame, WIN32APP_POSTPONEDESTROY, 0, 0);
     2771        return TRUE;
     2772    }
     2773
     2774    BOOL fOldChildDestructionInProgress = FALSE;
     2775    if(GetParent()) {
     2776        Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(GetParent());
     2777        if(window) {
     2778            fOldChildDestructionInProgress = window->IsChildDestructionInProgress();
     2779            window->SetChildDestructionInProgress(TRUE);
     2780            RELEASE_WNDOBJ(window);
     2781        }
     2782    }
     2783//hack end
     2784
     2785    BOOL ret = OSLibWinDestroyWindow(OS2HwndFrame);
     2786
     2787//hack alert; PM crashes if child calls DestroyWindow for parent/owner in WM_DESTROY
     2788//            handler; must postpone it
     2789    if(GetParent()) {
     2790        Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(GetParent());
     2791        if(window) {
     2792            window->SetChildDestructionInProgress(fOldChildDestructionInProgress);
     2793            RELEASE_WNDOBJ(window);
     2794        }
     2795    }
     2796//hack end
     2797    return ret;
    27632798}
    27642799//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.