X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0256cfeb6db72fb570ff043a2cdd214128b3ea2d..b8ddac49a37a01ca1cf89f97dc97c4945b50ddab:/src/os2/toplevel.cpp diff --git a/src/os2/toplevel.cpp b/src/os2/toplevel.cpp index a7a66c4f1e..badfc61835 100644 --- a/src/os2/toplevel.cpp +++ b/src/os2/toplevel.cpp @@ -36,6 +36,7 @@ #include "wx/intl.h" #include "wx/frame.h" #include "wx/control.h" + #include "wx/containr.h" // wxSetFocusToChild() #endif //WX_PRECOMP #include "wx/os2/private.h" @@ -592,20 +593,50 @@ bool wxTopLevelWindowOS2::Create( wxTopLevelWindowOS2::~wxTopLevelWindowOS2() { - wxTopLevelWindows.DeleteObject(this); + if (this == m_spHiddenParent) + { + // + // Stop [infinite] recursion which would otherwise happen when we do + // "delete ms_hiddenParent" below -- and we're not interested in doing + // anything of the rest below for that window because the rest of + // wxWindows doesn't even know about it + // + return; + } if (wxModelessWindows.Find(this)) wxModelessWindows.DeleteObject(this); // - // If this is the last top-level window, exit. + // After destroying an owned window, Windows activates the next top level + // window in Z order but it may be different from our owner (to reproduce + // this simply Alt-TAB to another application and back before closing the + // owned frame) whereas we always want to yield activation to our parent + // + if (HasFlag(wxFRAME_FLOAT_ON_PARENT)) + { + wxWindow* pParent = GetParent(); + + if (pParent) + { + ::WinSetWindowPos( GetHwndOf(pParent) + ,HWND_TOP + ,0, 0, 0, 0 + ,SWP_ZORDER + ); + } + } + + // + // If this is the last top-level window, we're going to exit and we should + // delete ms_hiddenParent now to avoid leaking it // - if (wxTheApp && (wxTopLevelWindows.Number() == 0)) + if (IsLastBeforeExit()) { - wxTheApp->SetTopWindow(NULL); - if ( wxTheApp->GetExitOnFrameDelete() ) + if (m_spHiddenParent) { - ::WinPostMsg(NULL, WM_QUIT, 0, 0); + delete m_spHiddenParent; + m_spHiddenParent = NULL; } } } // end of wxTopLevelWindowOS2::~wxTopLevelWindowOS2 @@ -722,15 +753,6 @@ bool wxTopLevelWindowOS2::Show( ::WinQueryWindowPos(hWndParent, &vSwp); m_bIconized = vSwp.fl & SWP_MINIMIZE; - if (hWndParent) - ::WinSetWindowPos( hWndParent - ,HWND_TOP - ,vSwp.x - ,vSwp.y - ,vSwp.cx - ,vSwp.cy - ,SWP_ZORDER | SWP_ACTIVATE | SWP_SHOW | SWP_MOVE - ); ::WinEnableWindow(hWndParent, TRUE); } }