From e2758e21753c00b8e36f11c003fd6cd0e5137391 Mon Sep 17 00:00:00 2001 From: Kevin Ollivier Date: Sun, 3 Jan 2010 23:59:32 +0000 Subject: [PATCH] Don't use a destroy event handler to disconnect the native control's delegate as the destroy event propagates and can cause the TLW to remove its delegate at unexpected times, such as when a child control is destroyed but the TLW remains active. Instead, do it in response to the Destroy() call. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63051 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/osx/nonownedwnd.h | 4 +++- src/osx/nonownedwnd_osx.cpp | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/wx/osx/nonownedwnd.h b/include/wx/osx/nonownedwnd.h index da7ede4551..eee92a7ea6 100644 --- a/include/wx/osx/nonownedwnd.h +++ b/include/wx/osx/nonownedwnd.h @@ -103,6 +103,8 @@ public: virtual void HandleResized( double timestampsec ); virtual void HandleMoved( double timestampsec ); virtual void HandleResizing( double timestampsec, wxRect* rect ); + + virtual bool Destroy(); protected: // common part of all ctors @@ -117,7 +119,7 @@ protected: wxShowEffect effect, unsigned timeout); - void OnWindowDestroy( wxWindowDestroyEvent &event); + virtual void WillBeDestroyed(); wxNonOwnedWindowImpl* m_nowpeer ; diff --git a/src/osx/nonownedwnd_osx.cpp b/src/osx/nonownedwnd_osx.cpp index 12d8d61aab..017107215f 100644 --- a/src/osx/nonownedwnd_osx.cpp +++ b/src/osx/nonownedwnd_osx.cpp @@ -147,9 +147,6 @@ bool wxNonOwnedWindow::Create(wxWindow *parent, if ( parent ) parent->AddChild(this); - wxBIND_OR_CONNECT_HACK(this, wxEVT_DESTROY, wxWindowDestroyEventHandler, - wxNonOwnedWindow::OnWindowDestroy, this); - return true; } @@ -169,10 +166,15 @@ wxNonOwnedWindow::~wxNonOwnedWindow() s_macDeactivateWindow = NULL; } -void wxNonOwnedWindow::OnWindowDestroy( wxWindowDestroyEvent &event) +bool wxNonOwnedWindow::Destroy() { - event.Skip(); + WillBeDestroyed(); + return wxWindow::Destroy(); +} + +void wxNonOwnedWindow::WillBeDestroyed() +{ if ( m_nowpeer ) m_nowpeer->WillBeDestroyed(); } -- 2.45.2