From: David Elliott Date: Mon, 14 Jul 2003 03:02:04 +0000 (+0000) Subject: In destructor, pass the NSView ownership to the base class X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/fe169919d8d60ce40edbd8b27dfc445487788bbf?ds=sidebyside In destructor, pass the NSView ownership to the base class Avoid extra if tests now that Associate/Disassociate do the test themselves git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21945 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/cocoa/toplevel.mm b/src/cocoa/toplevel.mm index f20e2baead..39b1b48f9d 100644 --- a/src/cocoa/toplevel.mm +++ b/src/cocoa/toplevel.mm @@ -28,6 +28,7 @@ #include "wx/app.h" #endif //WX_PRECOMP +#import #import // ---------------------------------------------------------------------------- // globals @@ -93,7 +94,12 @@ bool wxTopLevelWindowCocoa::Create(wxWindow *parent, wxTopLevelWindowCocoa::~wxTopLevelWindowCocoa() { + // Hand ownership of the content view to wxWindow so it can destroy + // itself properly. + NSView *view = [m_cocoaNSView retain]; SetNSWindow(NULL); + SetNSView(view); + [view release]; } // ---------------------------------------------------------------------------- @@ -104,8 +110,7 @@ void wxTopLevelWindowCocoa::SetNSWindow(WX_NSWindow cocoaNSWindow) { bool need_debug = cocoaNSWindow || m_cocoaNSWindow; if(need_debug) wxLogDebug("wxTopLevelWindowCocoa=%p::SetNSWindow [m_cocoaNSWindow=%p retainCount]=%d",this,m_cocoaNSWindow,[m_cocoaNSWindow retainCount]); - if(m_cocoaNSWindow) - DisassociateNSWindow(m_cocoaNSWindow); + DisassociateNSWindow(m_cocoaNSWindow); [cocoaNSWindow retain]; [m_cocoaNSWindow release]; m_cocoaNSWindow = cocoaNSWindow; @@ -113,8 +118,7 @@ void wxTopLevelWindowCocoa::SetNSWindow(WX_NSWindow cocoaNSWindow) SetNSView([m_cocoaNSWindow contentView]); else SetNSView(NULL); - if(m_cocoaNSWindow) - AssociateNSWindow(m_cocoaNSWindow); + AssociateNSWindow(m_cocoaNSWindow); if(need_debug) wxLogDebug("wxTopLevelWindowCocoa=%p::SetNSWindow [cocoaNSWindow=%p retainCount]=%d",this,cocoaNSWindow,[cocoaNSWindow retainCount]); }