Changeset 1311 for trunk/src


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

Window destruction fixes

Location:
trunk/src/user32
Files:
4 edited

Legend:

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

    r1306 r1311  
    1 /* $Id: pmwindow.cpp,v 1.29 1999-10-15 09:26:22 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.30 1999-10-15 13:52:54 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    261261
    262262        if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
    263             if (win32wnd->isChild())
    264                 hParent = win32wnd->getParent()->getOS2WindowHandle();
     263            if (win32wnd->isChild()) {
     264                if(win32wnd->getParent()) {
     265                        hParent = win32wnd->getParent()->getOS2WindowHandle();
     266                }
     267                else    break;
     268            }
    265269            else
    266270                hFrame = win32wnd->getOS2FrameWindowHandle();
     
    294298
    295299        if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
    296             if (win32wnd->isChild())
    297                 hParent = win32wnd->getParent()->getOS2WindowHandle();
     300            if (win32wnd->isChild()) {
     301                if(win32wnd->getParent()) {
     302                        hParent = win32wnd->getParent()->getOS2WindowHandle();
     303                }
     304                else    goto RunDefWndProc; //parent has just been destroyed
     305            }
    298306            else
    299307                hFrame = WinQueryWindow(hwnd, QW_PARENT);
  • 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;
  • trunk/src/user32/win32wbase.h

    r1281 r1311  
    1 /* $Id: win32wbase.h,v 1.22 1999-10-14 09:22:42 sandervl Exp $ */
     1/* $Id: win32wbase.h,v 1.23 1999-10-15 13:52:55 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    163163         BOOL   IsDialog()                    { return fIsDialog; };
    164164
     165         BOOL   IsWindowDestroyed()           { return fIsDestroyed; };
    165166         BOOL   IsWindowEnabled();
    166167         BOOL   IsWindowVisible();
     
    247248                                        //sent by PM and those sent by apps
    248249        BOOL    fNoSizeMsg;
     250        BOOL    fIsDestroyed;
    249251
    250252        PVOID   pOldFrameProc;
  • trunk/src/user32/win32wndchild.cpp

    r949 r1311  
    1 /* $Id: win32wndchild.cpp,v 1.1 1999-09-15 23:19:02 sandervl Exp $ */
     1/* $Id: win32wndchild.cpp,v 1.2 1999-10-15 13:52:56 sandervl Exp $ */
    22/*
    33 * Win32 Child/Parent window class for OS/2
     
    2929        parent->RemoveChild(this);
    3030  }
     31//SvL: PM sends WM_DESTROY for all the children
     32#if 0
    3133  if(children != 0) {
    3234        dprintf(("ChildWindow::~ChildWindow children not yet destroyed!!"));
    3335        DestroyChildren();
    3436  }
     37#endif
    3538}
    3639//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.