]> git.saurik.com Git - wxWidgets.git/commitdiff
switching to autorelease
authorStefan Csomor <csomor@advancedconcepts.ch>
Sun, 10 Dec 2006 13:19:50 +0000 (13:19 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Sun, 10 Dec 2006 13:19:50 +0000 (13:19 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43894 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/carbon/toolbar.cpp
src/mac/carbon/utils.cpp

index d3fcb494ac348e4fe6b75c7a637d64274324ede0..61fdc4325ab3b00124bddcbb82e21a8259bc744d 100644 (file)
@@ -19,6 +19,7 @@
     #include "wx/wx.h"
 #endif
 
+#include "wx/app.h"
 #include "wx/mac/uma.h"
 #include "wx/geometry.h"
 
@@ -115,7 +116,8 @@ public:
         {
             CFIndex count = CFGetRetainCount( m_toolbarItemRef ) ;
             wxASSERT_MSG( count == 1 , wxT("Reference Count of native tool was not 1 in wxToolBarTool destructor") );
-            CFRelease( m_toolbarItemRef );
+            wxTheApp->MacAddToAutorelease(m_toolbarItemRef);
+            CFRelease(m_toolbarItemRef);
             m_toolbarItemRef = NULL;
         }
 #endif
@@ -615,9 +617,11 @@ static pascal OSStatus ControlToolbarItemHandler( EventHandlerCallRef inCallRef,
                         // we've increased the ref count when creating this, so we decrease manually again in case
                         // it was never really installed and deinstalled
                         HIViewRef viewRef = object->viewRef ;
-                        if( viewRef && CFGetRetainCount( viewRef ) > 1 )
+                        if( viewRef && IsValidControlHandle( viewRef)  )
                         {
-                            CFRelease( viewRef ) ;
+                            CFIndex count =  CFGetRetainCount( viewRef ) ; 
+                            if ( count >= 1 )
+                                CFRelease( viewRef ) ;
                         }
                            free( object ) ;
                        result = noErr;
index 8e7cf1af166845f06a250cd78b572f0b53783696..85a38d0b49f9b57b540423bc0217be4383404a80 100644 (file)
@@ -865,10 +865,8 @@ void wxMacControl::Dispose()
 {
     wxASSERT_MSG( IsValidControlHandle(m_controlRef) , wxT("Invalid Control Handle (maybe already released) in Dispose") );
 
-    CFIndex count = CFGetRetainCount( m_controlRef ) ;
-    wxASSERT_MSG( count == 1 , wxT("Reference Count of native control was not 1 in Dispose") );
-
-    ::DisposeControl( m_controlRef );
+    // we cannot check the ref count here anymore, as autorelease objects might delete their refs later
+    CFRelease(m_controlRef);
     m_controlRef = NULL;
 }