removing event handlers on non-owned windows when the destroy event is sent
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62985 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1005,7 +1005,7 @@ public :
|
|||||||
wxNonOwnedWindowCarbonImpl();
|
wxNonOwnedWindowCarbonImpl();
|
||||||
virtual ~wxNonOwnedWindowCarbonImpl();
|
virtual ~wxNonOwnedWindowCarbonImpl();
|
||||||
|
|
||||||
virtual void Destroy() ;
|
virtual void WillBeDestroyed() ;
|
||||||
void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
|
void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
|
||||||
long style, long extraStyle, const wxString& name ) ;
|
long style, long extraStyle, const wxString& name ) ;
|
||||||
|
|
||||||
|
@@ -193,7 +193,7 @@ public :
|
|||||||
|
|
||||||
virtual ~wxNonOwnedWindowCocoaImpl();
|
virtual ~wxNonOwnedWindowCocoaImpl();
|
||||||
|
|
||||||
virtual void Destroy() ;
|
virtual void WillBeDestroyed() ;
|
||||||
void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
|
void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
|
||||||
long style, long extraStyle, const wxString& name ) ;
|
long style, long extraStyle, const wxString& name ) ;
|
||||||
|
|
||||||
|
@@ -653,7 +653,7 @@ public :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Destroy()
|
virtual void WillBeDestroyed()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -125,7 +125,7 @@ public :
|
|||||||
|
|
||||||
virtual ~wxNonOwnedWindowIPhoneImpl();
|
virtual ~wxNonOwnedWindowIPhoneImpl();
|
||||||
|
|
||||||
virtual void Destroy() ;
|
virtual void WillBeDestroyed() ;
|
||||||
void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
|
void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
|
||||||
long style, long extraStyle, const wxString& name ) ;
|
long style, long extraStyle, const wxString& name ) ;
|
||||||
|
|
||||||
|
@@ -116,6 +116,8 @@ protected:
|
|||||||
virtual bool OSXShowWithEffect(bool show,
|
virtual bool OSXShowWithEffect(bool show,
|
||||||
wxShowEffect effect,
|
wxShowEffect effect,
|
||||||
unsigned timeout);
|
unsigned timeout);
|
||||||
|
|
||||||
|
void OnWindowDestroy( wxWindowDestroyEvent &event);
|
||||||
|
|
||||||
wxNonOwnedWindowImpl* m_nowpeer ;
|
wxNonOwnedWindowImpl* m_nowpeer ;
|
||||||
|
|
||||||
|
@@ -1144,15 +1144,13 @@ wxNonOwnedWindowCarbonImpl::~wxNonOwnedWindowCarbonImpl()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNonOwnedWindowCarbonImpl::Destroy()
|
void wxNonOwnedWindowCarbonImpl::WillBeDestroyed()
|
||||||
{
|
{
|
||||||
if ( m_macEventHandler )
|
if ( m_macEventHandler )
|
||||||
{
|
{
|
||||||
::RemoveEventHandler((EventHandlerRef) m_macEventHandler);
|
::RemoveEventHandler((EventHandlerRef) m_macEventHandler);
|
||||||
m_macEventHandler = NULL ;
|
m_macEventHandler = NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPendingDelete.Append( new wxDeferredObjectDeleter( this ) ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNonOwnedWindowInstallTopLevelWindowEventHandler(WindowRef window, EventHandlerRef* handler, void *ref)
|
void wxNonOwnedWindowInstallTopLevelWindowEventHandler(WindowRef window, EventHandlerRef* handler, void *ref)
|
||||||
|
@@ -351,9 +351,9 @@ wxNonOwnedWindowCocoaImpl::~wxNonOwnedWindowCocoaImpl()
|
|||||||
[m_macWindow release];
|
[m_macWindow release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNonOwnedWindowCocoaImpl::Destroy()
|
void wxNonOwnedWindowCocoaImpl::WillBeDestroyed()
|
||||||
{
|
{
|
||||||
wxPendingDelete.Append( new wxDeferredObjectDeleter( this ) );
|
[m_macWindow setDelegate:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNonOwnedWindowCocoaImpl::Create( wxWindow* WXUNUSED(parent), const wxPoint& pos, const wxSize& size,
|
void wxNonOwnedWindowCocoaImpl::Create( wxWindow* WXUNUSED(parent), const wxPoint& pos, const wxSize& size,
|
||||||
|
@@ -90,9 +90,8 @@ wxNonOwnedWindowIPhoneImpl::~wxNonOwnedWindowIPhoneImpl()
|
|||||||
[m_macWindow release];
|
[m_macWindow release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNonOwnedWindowIPhoneImpl::Destroy()
|
void wxNonOwnedWindowIPhoneImpl::WillBeDestroyed()
|
||||||
{
|
{
|
||||||
wxPendingDelete.Append( new wxDeferredObjectDeleter( this ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNonOwnedWindowIPhoneImpl::Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
|
void wxNonOwnedWindowIPhoneImpl::Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
|
||||||
|
@@ -147,6 +147,9 @@ bool wxNonOwnedWindow::Create(wxWindow *parent,
|
|||||||
if ( parent )
|
if ( parent )
|
||||||
parent->AddChild(this);
|
parent->AddChild(this);
|
||||||
|
|
||||||
|
wxBIND_OR_CONNECT_HACK(this, wxEVT_DESTROY, wxWindowDestroyEventHandler,
|
||||||
|
wxNonOwnedWindow::OnWindowDestroy, this);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,12 +162,21 @@ wxNonOwnedWindow::~wxNonOwnedWindow()
|
|||||||
DestroyChildren();
|
DestroyChildren();
|
||||||
|
|
||||||
delete m_nowpeer;
|
delete m_nowpeer;
|
||||||
|
m_nowpeer = NULL;
|
||||||
|
|
||||||
// avoid dangling refs
|
// avoid dangling refs
|
||||||
if ( s_macDeactivateWindow == this )
|
if ( s_macDeactivateWindow == this )
|
||||||
s_macDeactivateWindow = NULL;
|
s_macDeactivateWindow = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxNonOwnedWindow::OnWindowDestroy( wxWindowDestroyEvent &event)
|
||||||
|
{
|
||||||
|
event.Skip();
|
||||||
|
|
||||||
|
if ( m_nowpeer )
|
||||||
|
m_nowpeer->WillBeDestroyed();
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxNonOwnedWindow misc
|
// wxNonOwnedWindow misc
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user