X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5c6eb3a84be918dcfed2496d014549e13af0f0e9..a01d6442f4dcf2d30d52e50bc8c8410066f76265:/include/wx/osx/core/cfref.h diff --git a/include/wx/osx/core/cfref.h b/include/wx/osx/core/cfref.h index f5251ab1c0..90c7ae4158 100644 --- a/include/wx/osx/core/cfref.h +++ b/include/wx/osx/core/cfref.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/mac/corefoundation/cfref.h +// Name: wx/osx/core/cfref.h // Purpose: wxCFRef template class // Author: David Elliott // Modified by: Stefan Csomor @@ -9,7 +9,7 @@ // Licence: wxWindows licence // Notes: See http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/index.html ///////////////////////////////////////////////////////////////////////////// -/*! @header wx/mac/corefoundation/cfref.h +/*! @header wx/osx/core/cfref.h @abstract wxCFRef template class @discussion FIXME: Convert doc tags to something less buggy with C++ */ @@ -234,9 +234,12 @@ public: */ wxCFRef& operator=(const wxCFRef& otherRef) { - wxCFRetain(otherRef.m_ptr); - wxCFRelease(m_ptr); - m_ptr = otherRef.m_ptr; + if (this != &otherRef) + { + wxCFRetain(otherRef.m_ptr); + wxCFRelease(m_ptr); + m_ptr = otherRef.m_ptr; + } return *this; } @@ -308,6 +311,15 @@ public: wxCFRelease(m_ptr); m_ptr = p; // Automatic conversion should occur } + + // Release the pointer, i.e. give up its ownership. + refType release() + { + refType p = m_ptr; + m_ptr = NULL; + return p; + } + protected: /*! @var m_ptr The raw pointer. */