From: Vadim Zeitlin Date: Sat, 15 Mar 2008 02:12:20 +0000 (+0000) Subject: call OnNativeDestroyed() if the native window is destroyed independently from us X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/9eff73c60d89cbc4ef76e7f620bb74aea347b772 call OnNativeDestroyed() if the native window is destroyed independently from us git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52527 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/nativewin.cpp b/src/msw/nativewin.cpp index 3ac00548a7..6b3649b842 100644 --- a/src/msw/nativewin.cpp +++ b/src/msw/nativewin.cpp @@ -56,7 +56,23 @@ bool wxNativeContainerWindow::Create(wxNativeContainerWindowHandle hwnd) void wxNativeContainerWindow::OnNativeDestroyed() { - // currently this is not called so nothing to do here + // don't use Close() or even Destroy() here, we really don't want to keep + // an object using a no more existing HWND around for longer than necessary + delete this; +} + +WXLRESULT wxNativeContainerWindow::MSWWindowProc(WXUINT nMsg, + WXWPARAM wParam, + WXLPARAM lParam) +{ + if ( nMsg == WM_DESTROY ) + { + OnNativeDestroyed(); + + return 0; + } + + return wxTopLevelWindow::MSWWindowProc(nMsg, wParam, lParam); } wxNativeContainerWindow::~wxNativeContainerWindow()