switching to autorelease

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43894 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2006-12-10 13:19:50 +00:00
parent 9611686694
commit 83f787ba21
2 changed files with 9 additions and 7 deletions

View File

@@ -19,6 +19,7 @@
#include "wx/wx.h" #include "wx/wx.h"
#endif #endif
#include "wx/app.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#include "wx/geometry.h" #include "wx/geometry.h"
@@ -115,6 +116,7 @@ public:
{ {
CFIndex count = CFGetRetainCount( m_toolbarItemRef ) ; CFIndex count = CFGetRetainCount( m_toolbarItemRef ) ;
wxASSERT_MSG( count == 1 , wxT("Reference Count of native tool was not 1 in wxToolBarTool destructor") ); wxASSERT_MSG( count == 1 , wxT("Reference Count of native tool was not 1 in wxToolBarTool destructor") );
wxTheApp->MacAddToAutorelease(m_toolbarItemRef);
CFRelease(m_toolbarItemRef); CFRelease(m_toolbarItemRef);
m_toolbarItemRef = NULL; m_toolbarItemRef = NULL;
} }
@@ -615,8 +617,10 @@ static pascal OSStatus ControlToolbarItemHandler( EventHandlerCallRef inCallRef,
// we've increased the ref count when creating this, so we decrease manually again in case // we've increased the ref count when creating this, so we decrease manually again in case
// it was never really installed and deinstalled // it was never really installed and deinstalled
HIViewRef viewRef = object->viewRef ; HIViewRef viewRef = object->viewRef ;
if( viewRef && CFGetRetainCount( viewRef ) > 1 ) if( viewRef && IsValidControlHandle( viewRef) )
{ {
CFIndex count = CFGetRetainCount( viewRef ) ;
if ( count >= 1 )
CFRelease( viewRef ) ; CFRelease( viewRef ) ;
} }
free( object ) ; free( object ) ;

View File

@@ -865,10 +865,8 @@ void wxMacControl::Dispose()
{ {
wxASSERT_MSG( IsValidControlHandle(m_controlRef) , wxT("Invalid Control Handle (maybe already released) in Dispose") ); wxASSERT_MSG( IsValidControlHandle(m_controlRef) , wxT("Invalid Control Handle (maybe already released) in Dispose") );
CFIndex count = CFGetRetainCount( m_controlRef ) ; // we cannot check the ref count here anymore, as autorelease objects might delete their refs later
wxASSERT_MSG( count == 1 , wxT("Reference Count of native control was not 1 in Dispose") ); CFRelease(m_controlRef);
::DisposeControl( m_controlRef );
m_controlRef = NULL; m_controlRef = NULL;
} }