From: Stefan Csomor Date: Sun, 9 Feb 2003 08:54:08 +0000 (+0000) Subject: corrected disposal for b/w cursors and creation and disposal of colour cursors X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/07c76470e925815a6e3b42c38b3128f32b1e0e84 corrected disposal for b/w cursors and creation and disposal of colour cursors git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19154 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/mac/carbon/cursor.cpp b/src/mac/carbon/cursor.cpp index ad1d54abb0..3669791601 100644 --- a/src/mac/carbon/cursor.cpp +++ b/src/mac/carbon/cursor.cpp @@ -63,9 +63,11 @@ wxCursorRefData::~wxCursorRefData() else if ( m_disposeHandle ) { ::DisposeHandle( (Handle ) m_hCursor ) ; - } else if ( m_releaseHandle ) + } + else if ( m_releaseHandle ) { - ::ReleaseResource( (Handle ) m_hCursor ) ; + // we don't release the resource since it may already + // be in use again } } @@ -166,16 +168,30 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho #endif wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetNamedResource( 'crsr' , theName ) ; - if ( M_CURSORDATA->m_hCursor ) + Handle resHandle = ::GetNamedResource( 'crsr' , theName ) ; + if ( resHandle ) { - M_CURSORDATA->m_isColorCursor = true ; + short theId = -1 ; + OSType theType ; + GetResInfo( resHandle , &theId , &theType , theName ) ; + ReleaseResource( resHandle ) ; + M_CURSORDATA->m_hCursor = GetCCursor( theId ) ; + if ( M_CURSORDATA->m_hCursor ) + M_CURSORDATA->m_isColorCursor = true ; } else { - M_CURSORDATA->m_hCursor = ::GetNamedResource( 'CURS' , theName ) ; - if ( M_CURSORDATA->m_hCursor ) - M_CURSORDATA->m_releaseHandle = true ; + Handle resHandle = ::GetNamedResource( 'CURS' , theName ) ; + if ( resHandle ) + { + short theId = -1 ; + OSType theType ; + GetResInfo( resHandle , &theId , &theType , theName ) ; + ReleaseResource( resHandle ) ; + M_CURSORDATA->m_hCursor = GetCursor( theId ) ; + if ( M_CURSORDATA->m_hCursor ) + M_CURSORDATA->m_releaseHandle = true ; + } } } else diff --git a/src/mac/cursor.cpp b/src/mac/cursor.cpp index ad1d54abb0..3669791601 100644 --- a/src/mac/cursor.cpp +++ b/src/mac/cursor.cpp @@ -63,9 +63,11 @@ wxCursorRefData::~wxCursorRefData() else if ( m_disposeHandle ) { ::DisposeHandle( (Handle ) m_hCursor ) ; - } else if ( m_releaseHandle ) + } + else if ( m_releaseHandle ) { - ::ReleaseResource( (Handle ) m_hCursor ) ; + // we don't release the resource since it may already + // be in use again } } @@ -166,16 +168,30 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho #endif wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetNamedResource( 'crsr' , theName ) ; - if ( M_CURSORDATA->m_hCursor ) + Handle resHandle = ::GetNamedResource( 'crsr' , theName ) ; + if ( resHandle ) { - M_CURSORDATA->m_isColorCursor = true ; + short theId = -1 ; + OSType theType ; + GetResInfo( resHandle , &theId , &theType , theName ) ; + ReleaseResource( resHandle ) ; + M_CURSORDATA->m_hCursor = GetCCursor( theId ) ; + if ( M_CURSORDATA->m_hCursor ) + M_CURSORDATA->m_isColorCursor = true ; } else { - M_CURSORDATA->m_hCursor = ::GetNamedResource( 'CURS' , theName ) ; - if ( M_CURSORDATA->m_hCursor ) - M_CURSORDATA->m_releaseHandle = true ; + Handle resHandle = ::GetNamedResource( 'CURS' , theName ) ; + if ( resHandle ) + { + short theId = -1 ; + OSType theType ; + GetResInfo( resHandle , &theId , &theType , theName ) ; + ReleaseResource( resHandle ) ; + M_CURSORDATA->m_hCursor = GetCursor( theId ) ; + if ( M_CURSORDATA->m_hCursor ) + M_CURSORDATA->m_releaseHandle = true ; + } } } else