]> git.saurik.com Git - wxWidgets.git/commitdiff
Removed dst buffer delete responsibility from wxAnyValueType::CopyBuffer(), clarified...
authorJaakko Salli <jaakko.salli@dnainternet.net>
Tue, 29 Sep 2009 13:38:20 +0000 (13:38 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Tue, 29 Sep 2009 13:38:20 +0000 (13:38 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62198 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/any.h
interface/wx/any.h
src/common/any.cpp

index 102f75926e1597afc070560e5b1d6027dfd604dd..0784b66480e9e0bc18e236a274230ca1673bcd90 100644 (file)
@@ -83,9 +83,14 @@ public:
     virtual void DeleteValue(wxAnyValueBuffer& buf) const = 0;
 
     /**
-        Implement this for buffer-to-buffer copy. src.m_ptr can
-        be expected to be NULL if value type of previously stored
-        data was different.
+        Implement this for buffer-to-buffer copy.
+
+        @param src
+            This is the source data buffer.
+
+        @param dst
+            This is the destination data buffer that is in either
+            uninitialized or freed state.
     */
     virtual void CopyBuffer(const wxAnyValueBuffer& src,
                             wxAnyValueBuffer& dst) const = 0;
@@ -259,13 +264,11 @@ public:
     virtual void DeleteValue(wxAnyValueBuffer& buf) const
     {
         Ops::DeleteValue(buf);
-        buf.m_ptr = NULL;  // This is important
     }
 
     virtual void CopyBuffer(const wxAnyValueBuffer& src,
                             wxAnyValueBuffer& dst) const
     {
-        Ops::DeleteValue(dst);
         Ops::SetValue(Ops::GetValue(src), dst);
     }
 
@@ -767,12 +770,15 @@ private:
     // Assignment functions
     void AssignAny(const wxAny& any)
     {
-        if ( !any.m_type->IsSameType(m_type) )
-        {
-            m_type->DeleteValue(m_buffer);
-            m_type = any.m_type;
-        }
-        m_type->CopyBuffer(any.m_buffer, m_buffer);
+        // Must delete value - CopyBuffer() never does that
+        m_type->DeleteValue(m_buffer);
+
+        wxAnyValueType* newType = any.m_type;
+
+        if ( !newType->IsSameType(m_type) )
+            m_type = newType;
+
+        newType->CopyBuffer(any.m_buffer, m_buffer);
     }
 
     template<typename T>
index 5623c8d9e0b5efecf6e1049cea7f142f18e0e7fb..c1893fbfe6ba1fba0101c534811552ac07d8972c 100644 (file)
@@ -321,6 +321,8 @@ union wxAnyValueBuffer
                                     wxAnyValueBuffer& dst) const
             {
                 // TODO: Copy value from one buffer to another.
+                //       dst is already uninitialized and does not
+                //       need to be freed.
             }
 
             virtual bool ConvertValue(const wxAnyValueBuffer& src,
@@ -394,9 +396,14 @@ public:
                               wxAnyValueBuffer& dst) const = 0;
 
     /**
-        Implement this for buffer-to-buffer copy. src.m_ptr can
-        be expected to be NULL if value type of previously stored
-        data was different.
+        Implement this for buffer-to-buffer copy.
+
+        @param src
+            This is the source data buffer.
+
+        @param dst
+            This is the destination data buffer that is in either
+            uninitialized or freed state.
     */
     virtual void CopyBuffer(const wxAnyValueBuffer& src,
                             wxAnyValueBuffer& dst) const = 0;
index 9ac859b6e17712fea33beb575bcb32e735da2030..01658ab8b738b69a56c682941c26aa6d6ee28922 100644 (file)
@@ -354,12 +354,12 @@ class wxAnyValueTypeImpl<wxAnyNullValue> : public wxAnyValueType
 {
     WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxAnyNullValue>)
 public:
+    // Dummy implementations
     virtual void DeleteValue(wxAnyValueBuffer& buf) const
     {
-        buf.m_ptr = NULL;  // This is important
+        wxUnusedVar(buf);
     }
 
-    // Dummy implementations
     virtual void CopyBuffer(const wxAnyValueBuffer& src,
                             wxAnyValueBuffer& dst) const
     {