]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/buffer.h
Split utility functions into base (in utilsexc_base.cpp) and gui (src/osx/carbon...
[wxWidgets.git] / include / wx / buffer.h
index 1144aa420d0392c9a9d7121ee75a7c8110df69b9..32443237373ac92b4429d53f69cfe227f3dac051 100644 (file)
@@ -59,7 +59,10 @@ public:
         DecRef();
     }
 
-    CharType *release()
+    // NB: this method is only const for backward compatibility. It used to
+    //     be needed for auto_ptr-like semantics of the copy ctor, but now
+    //     that ref-counting is used, it's not really needed.
+    CharType *release() const
     {
         if ( m_data == &NullData )
             return NULL;
@@ -68,8 +71,11 @@ public:
         wxASSERT_MSG( m_data->m_ref == 1, _T("can't release shared buffer") );
 
         CharType *p = m_data->m_str;
-        m_data->m_str = NULL;
-        DecRef();
+
+        wxCharTypeBuffer *self = wx_const_cast(wxCharTypeBuffer*, this);
+        self->m_data->m_str = NULL;
+        self->DecRef();
+
         return p;
     }
 
@@ -162,7 +168,14 @@ private:
 
     // placeholder for NULL string, to simplify this code
     // NB: this is defined in string.cpp, not (non-existent) buffer.cpp
+#ifdef __MINGW32__
+    // MinGW requires explicit WXDLLIMPEXP_DATA_BASE to avoid compilation
+    // errors
+    static WXDLLIMPEXP_DATA_BASE(Data) NullData;
+#else
+    // but Visual C++ doesn't like it
     static Data NullData;
+#endif
 
     void IncRef()
     {