Ignore:
Timestamp:
Oct 15, 1999, 3:52:56 PM (26 years ago)
Author:
sandervl
Message:

Window destruction fixes

File:
1 edited

Legend:

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

    r1307 r1311  
    1 /* $Id: win32wbase.cpp,v 1.44 1999-10-15 10:03:15 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.45 1999-10-15 13:52:54 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    101101  fInternalMsg     = FALSE;
    102102  fNoSizeMsg       = FALSE;
     103  fIsDestroyed     = FALSE;
    103104
    104105  windowNameA      = NULL;
     
    161162Win32BaseWindow::~Win32BaseWindow()
    162163{
    163   OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
    164   OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
    165 
    166   if (isOwnDC())
     164    OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
     165    OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
     166
     167    if(getParent() && getParent()->getFirstChild() == this && getNextChild() == NULL)
     168    {
     169        //if we're the last child that's being destroyed and our
     170        //parent window was also destroyed, then we delete the parent object
     171        if(getParent()->IsWindowDestroyed())
     172        {
     173            dprintf(("Last Child (%x) destroyed, get rid of our parent window (%x)", getWindowHandle(), getParent()->getWindowHandle()));
     174            delete getParent();
     175            setParent(NULL);  //or else we'll crash in the dtor of the ChildWindow class
     176        }
     177    }
     178    if (isOwnDC())
    167179        releaseOwnDC (ownDC);
    168180
    169   if(Win32Hwnd)
     181    if(Win32Hwnd)
    170182        HwFreeWindowHandle(Win32Hwnd);
    171183
    172   if(userWindowLong)
     184    if(userWindowLong)
    173185        free(userWindowLong);
    174   if(windowNameA) {
     186    if(windowNameA) {
    175187        free(windowNameA);
    176188        windowNameA = NULL;
    177   }
    178   if(windowNameW) {
     189    }
     190    if(windowNameW) {
    179191        free(windowNameW);
    180192        windowNameW = NULL;
    181   }
    182   if(vertScrollInfo) {
     193    }
     194    if(vertScrollInfo) {
    183195        free(vertScrollInfo);
    184196        vertScrollInfo = NULL;
    185   }
    186   if(horzScrollInfo) {
     197    }
     198    if(horzScrollInfo) {
    187199        free(horzScrollInfo);
    188200        horzScrollInfo = NULL;
    189   }
     201    }
    190202  //TODO: Destroy windows if they're not associated with our window anymore (showwindow false)?
    191203//  hwndHorzScroll
     
    197209BOOL Win32BaseWindow::isChild()
    198210{
    199     return (dwStyle & WS_CHILD) != 0;
     211    return ((dwStyle & WS_CHILD) != 0);
    200212}
    201213//******************************************************************************
     
    655667        return 0; //app handles this message
    656668  }
    657   delete this;
    658669  return 1;
    659670}
     
    663674{
    664675 ULONG rc;
    665 
    666   rc = SendInternalMessageA(WM_DESTROY, 0, 0);
    667   delete this;
    668   return rc;
     676 Win32BaseWindow *child;
     677
     678    //According to the SDK, WM_PARENTNOTIFY messages are sent to the parent (this window)
     679    //before any window destruction has begun
     680    child = (Win32BaseWindow *)getFirstChild();
     681    while(child) {
     682        child->NotifyParent(WM_DESTROY, 0, 0);
     683
     684        child = (Win32BaseWindow *)child->getNextChild();
     685    }
     686    SendInternalMessageA(WM_DESTROY, 0, 0);
     687
     688    fIsDestroyed = TRUE;
     689    if(getFirstChild() == NULL) {
     690        delete this;
     691    }
     692    return 1;
    669693}
    670694//******************************************************************************
     
    16611685
    16621686        case WM_DESTROY:
     1687                win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    16631688                rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    16641689                break;
     
    17141739        case WM_DESTROY:
    17151740                win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    1716                 NotifyParent(Msg, wParam, lParam);
    17171741                rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    17181742                break;
     
    17621786        case WM_DESTROY:
    17631787                win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    1764                 NotifyParent(Msg, wParam, lParam);
    17651788                rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    17661789                break;
     
    18101833        case WM_DESTROY:
    18111834                win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    1812                 NotifyParent(Msg, wParam, lParam);
    18131835                rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    18141836                break;
Note: See TracChangeset for help on using the changeset viewer.