]> git.saurik.com Git - wxWidgets.git/commitdiff
modeling subclassing along msw, unsubclassing filedialog at end of ShowModal, fixes...
authorStefan Csomor <csomor@advancedconcepts.ch>
Tue, 7 Sep 2010 06:51:13 +0000 (06:51 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Tue, 7 Sep 2010 06:51:13 +0000 (06:51 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65474 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/osx/nonownedwnd.h
src/osx/carbon/filedlg.cpp
src/osx/cocoa/filedlg.mm
src/osx/nonownedwnd_osx.cpp

index 843b7589b8b20bf0c0c4ccbdc65a4cd9865cd420..8191fa3fefca5a502bff9278fd3a420718b258d8 100644 (file)
@@ -58,6 +58,9 @@ public:
     bool Create(wxWindow *parent, WXWindow nativeWindow);
     
     virtual ~wxNonOwnedWindow();
+    
+    virtual void SubclassWin(WXWindow nativeWindow);
+    virtual void UnsubclassWin();
 
     virtual wxPoint GetClientAreaOrigin() const;
 
index 158846b529923de8e3c7190e5e7935401ae6fdaf..fc9bb2bba9dbb7c08a918360593eb50d51845fef 100644 (file)
@@ -602,6 +602,7 @@ int wxFileDialog::ShowModal()
         m_dir = wxPathOnly(m_path);
     }
 
+    UnsubclassWin();
     ::NavDisposeReply(&navReply);
     ::NavDialogDispose(dialog);
 
index 4d5aaad01fcae3e5b3352ea9241c3b9f5f224ed7..3e5de2867b0597aa3fd9084a293e1a3f19f6bb30 100644 (file)
@@ -275,6 +275,7 @@ int wxFileDialog::ShowModal()
         returnCode = [sPanel runModalForDirectory:dir.AsNSString() file:file.AsNSString() ];
         ModalFinishedCallback(sPanel, returnCode);
 
+        UnsubclassWin();
         [sPanel setAccessoryView:nil];
     }
     else
@@ -295,6 +296,7 @@ int wxFileDialog::ShowModal()
 
         ModalFinishedCallback(oPanel, returnCode);
         
+        UnsubclassWin();
         [oPanel setAccessoryView:nil];
         
         if ( types != nil )
index 5ed8b5993fc4f30ab834ac02a5790b28d1a3328e..b8145b42164187a88c0092220c7f425eba315971 100644 (file)
@@ -149,17 +149,39 @@ bool wxNonOwnedWindow::Create(wxWindow *parent,
 
 bool wxNonOwnedWindow::Create(wxWindow *parent, WXWindow nativeWindow)
 {
-    m_nowpeer = wxNonOwnedWindowImpl::CreateNonOwnedWindow(this, parent, nativeWindow );
+    if ( parent )
+        parent->AddChild(this);
+    
+    SubclassWin(nativeWindow);
+    
+    return true;
+}
+
+void wxNonOwnedWindow::SubclassWin(WXWindow nativeWindow)
+{
+    wxASSERT_MSG( !m_isNativeWindowWrapper, wxT("subclassing window twice?") );
+    wxASSERT_MSG( m_nowpeer == NULL, wxT("window already was created") );
+
+    m_nowpeer = wxNonOwnedWindowImpl::CreateNonOwnedWindow(this, GetParent(), nativeWindow );
     m_isNativeWindowWrapper = true;
     wxNonOwnedWindowImpl::Associate( m_nowpeer->GetWXWindow() , m_nowpeer ) ;
     m_peer = wxWidgetImpl::CreateContentView(this);
+}
 
-    if ( parent )
-        parent->AddChild(this);
+void wxNonOwnedWindow::UnsubclassWin()
+{
+    wxASSERT_MSG( m_isNativeWindowWrapper, wxT("window was not subclassed") );
+
+    if ( GetParent() )
+        GetParent()->RemoveChild(this);
     
-    return true;
+    wxNonOwnedWindowImpl::RemoveAssociations(m_nowpeer) ;    
+    m_isNativeWindowWrapper = false;
+    wxDELETE(m_nowpeer);
+    wxDELETE(m_peer);
 }
 
+
 wxNonOwnedWindow::~wxNonOwnedWindow()
 {
     SendDestroyEvent();