]> git.saurik.com Git - wxWidgets.git/commitdiff
removing event handlers on non-owned windows when the destroy event is sent
authorStefan Csomor <csomor@advancedconcepts.ch>
Fri, 25 Dec 2009 09:47:30 +0000 (09:47 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Fri, 25 Dec 2009 09:47:30 +0000 (09:47 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62985 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/osx/carbon/private.h
include/wx/osx/cocoa/private.h
include/wx/osx/core/private.h
include/wx/osx/iphone/private.h
include/wx/osx/nonownedwnd.h
src/osx/carbon/nonownedwnd.cpp
src/osx/cocoa/nonownedwnd.mm
src/osx/iphone/nonownedwnd.mm
src/osx/nonownedwnd_osx.cpp

index e63edd48913812edcc527fcb16a6f32f2499830f..c677e8331612a92b9799e6aededd784b1e72463e 100644 (file)
@@ -1005,7 +1005,7 @@ public :
     wxNonOwnedWindowCarbonImpl();
     virtual ~wxNonOwnedWindowCarbonImpl();
 
-    virtual void Destroy() ;
+    virtual void WillBeDestroyed() ;
     void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
     long style, long extraStyle, const wxString& name ) ;
 
index dabd225172be15e63d8c894203d8616b4bf10fc4..dc7478372c5a9e0da21fb3eaaa842c5615b0b6af 100644 (file)
@@ -193,7 +193,7 @@ public :
 
     virtual ~wxNonOwnedWindowCocoaImpl();
 
-    virtual void Destroy() ;
+    virtual void WillBeDestroyed() ;
     void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
     long style, long extraStyle, const wxString& name ) ;
 
index 6f64bc39c1a8d6dbdca5384e97143863decdebcc..c0de78f269fb493ab4edd3630eb8475f9571df51 100644 (file)
@@ -653,7 +653,7 @@ public :
     {
     }
 
-    virtual void Destroy()
+    virtual void WillBeDestroyed()
     {
     }
 
index 4faad3d7bfe5c22589468b6135c13124d15d0204..5db08c64aa95db774160173050965bd9e54f37c8 100644 (file)
@@ -125,7 +125,7 @@ public :
 
     virtual ~wxNonOwnedWindowIPhoneImpl();
 
-    virtual void Destroy() ;
+    virtual void WillBeDestroyed() ;
     void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
     long style, long extraStyle, const wxString& name ) ;
 
index cf537e15ec8b141b4f8a7c5663d458fbcc29b0d8..da7ede4551c41e3f12c74e01b10a2c9dd25bde5b 100644 (file)
@@ -116,6 +116,8 @@ protected:
     virtual bool OSXShowWithEffect(bool show,
                                    wxShowEffect effect,
                                    unsigned timeout);
+    
+    void OnWindowDestroy( wxWindowDestroyEvent &event);
 
     wxNonOwnedWindowImpl* m_nowpeer ;
 
index 75077bc46e8a4c11e00cdb9ed5980efb8b434d5a..192f8f5a2455b658740002b4979ae547538fb556 100644 (file)
@@ -1144,15 +1144,13 @@ wxNonOwnedWindowCarbonImpl::~wxNonOwnedWindowCarbonImpl()
 
 }
 
-void wxNonOwnedWindowCarbonImpl::Destroy()
+void wxNonOwnedWindowCarbonImpl::WillBeDestroyed()
 {
     if ( m_macEventHandler )
     {
         ::RemoveEventHandler((EventHandlerRef) m_macEventHandler);
         m_macEventHandler = NULL ;
     }
-
-    wxPendingDelete.Append( new wxDeferredObjectDeleter( this ) ) ;
 }
 
 void wxNonOwnedWindowInstallTopLevelWindowEventHandler(WindowRef window, EventHandlerRef* handler, void *ref)
index 9ed1300159c7dd4b7858798e6daf7a2301961451..76e2f4b9d549672ce776bd5c8516a61bd01444b0 100644 (file)
@@ -351,9 +351,9 @@ wxNonOwnedWindowCocoaImpl::~wxNonOwnedWindowCocoaImpl()
     [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,
index a1dbf134b8ad063fa779ed2f33d907c24cd6aa44..d50c0cfc313fe5f8274ecb00749d7c9b5966bfcd 100644 (file)
@@ -90,9 +90,8 @@ wxNonOwnedWindowIPhoneImpl::~wxNonOwnedWindowIPhoneImpl()
     [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,
index 9adc5647d549121fb5de9ecb7435a6e629451920..12d8d61aab9248148870d92e23550a44214521a6 100644 (file)
@@ -147,6 +147,9 @@ bool wxNonOwnedWindow::Create(wxWindow *parent,
     if ( parent )
         parent->AddChild(this);
 
+    wxBIND_OR_CONNECT_HACK(this, wxEVT_DESTROY, wxWindowDestroyEventHandler,
+                           wxNonOwnedWindow::OnWindowDestroy, this);
+
     return true;
 }
 
@@ -159,12 +162,21 @@ wxNonOwnedWindow::~wxNonOwnedWindow()
     DestroyChildren();
 
     delete m_nowpeer;
+    m_nowpeer = NULL;
 
     // avoid dangling refs
     if ( s_macDeactivateWindow == this )
         s_macDeactivateWindow = NULL;
 }
 
+void wxNonOwnedWindow::OnWindowDestroy( wxWindowDestroyEvent &event)
+{
+    event.Skip();
+    
+    if ( m_nowpeer )
+        m_nowpeer->WillBeDestroyed();
+}
+
 // ----------------------------------------------------------------------------
 // wxNonOwnedWindow misc
 // ----------------------------------------------------------------------------