]> git.saurik.com Git - wxWidgets.git/commitdiff
In destructor, pass the NSView ownership to the base class
authorDavid Elliott <dfe@tgwbd.org>
Mon, 14 Jul 2003 03:02:04 +0000 (03:02 +0000)
committerDavid Elliott <dfe@tgwbd.org>
Mon, 14 Jul 2003 03:02:04 +0000 (03:02 +0000)
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

src/cocoa/toplevel.mm

index f20e2baead48347b356c29fe23cb97c664503d82..39b1b48f9dea7c1b54af0eb3ac073de756261d54 100644 (file)
@@ -28,6 +28,7 @@
     #include "wx/app.h"
 #endif //WX_PRECOMP
 
+#import <AppKit/NSView.h>
 #import <AppKit/NSWindow.h>
 // ----------------------------------------------------------------------------
 // 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]);
 }