From: Stefan Csomor Date: Tue, 7 Sep 2010 06:51:13 +0000 (+0000) Subject: modeling subclassing along msw, unsubclassing filedialog at end of ShowModal, fixes... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/d623e8b18ae634911b62fcb088b707dff12f0858 modeling subclassing along msw, unsubclassing filedialog at end of ShowModal, fixes #12236 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65474 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/osx/nonownedwnd.h b/include/wx/osx/nonownedwnd.h index 843b7589b8..8191fa3fef 100644 --- a/include/wx/osx/nonownedwnd.h +++ b/include/wx/osx/nonownedwnd.h @@ -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; diff --git a/src/osx/carbon/filedlg.cpp b/src/osx/carbon/filedlg.cpp index 158846b529..fc9bb2bba9 100644 --- a/src/osx/carbon/filedlg.cpp +++ b/src/osx/carbon/filedlg.cpp @@ -602,6 +602,7 @@ int wxFileDialog::ShowModal() m_dir = wxPathOnly(m_path); } + UnsubclassWin(); ::NavDisposeReply(&navReply); ::NavDialogDispose(dialog); diff --git a/src/osx/cocoa/filedlg.mm b/src/osx/cocoa/filedlg.mm index 4d5aaad01f..3e5de2867b 100644 --- a/src/osx/cocoa/filedlg.mm +++ b/src/osx/cocoa/filedlg.mm @@ -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 ) diff --git a/src/osx/nonownedwnd_osx.cpp b/src/osx/nonownedwnd_osx.cpp index 5ed8b5993f..b8145b4216 100644 --- a/src/osx/nonownedwnd_osx.cpp +++ b/src/osx/nonownedwnd_osx.cpp @@ -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();