]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/osx/core/cfref.h
Don't use a destroy event handler to disconnect the native control's delegate as...
[wxWidgets.git] / include / wx / osx / core / cfref.h
index f5251ab1c07ef335b0b7244e6ffcc0b14a503dd6..cb4f6364986b02f800125a951d35a03f73a41e9c 100644 (file)
@@ -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.
     */