]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed bug: Settings property attribute to wxNullVariant would cause GetAttribute...
authorJaakko Salli <jaakko.salli@dnainternet.net>
Thu, 25 Sep 2008 16:13:32 +0000 (16:13 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Thu, 25 Sep 2008 16:13:32 +0000 (16:13 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55870 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

interface/wx/propgrid/property.h
interface/wx/propgrid/propgridiface.h
samples/propgrid/tests.cpp
src/propgrid/property.cpp

index 83947621270f221247af81b425b89494b964861a..cd267eb3fd3f593737266b596cf9266916390262 100644 (file)
@@ -1144,6 +1144,9 @@ public:
 
         @param value
             Value of attribute.
+
+        @remarks Setting attribute's value to Null variant will simply remove it
+                from property's set of attributes.
     */
     void SetAttribute( const wxString& name, wxVariant value );
 
index 950c16c8d881b6c761ab924496b3f17555da78c7..32932af3106e144109cd03a606361e87b763427d 100644 (file)
@@ -659,6 +659,9 @@ public:
         Value of attribute.
         @param argFlags
         Optional. Use wxPG_RECURSE to set the attribute to child properties recursively.
+
+        @remarks Setting attribute's value to Null variant will simply remove it
+                from property's set of attributes.
     */
     void SetPropertyAttribute( wxPGPropArg id, const wxString& attrName, wxVariant value, long argFlags = 0 )
     {
index 7685b2978d71f67ce2fc91f098afeadfff01da27..fcbb3e6a048ff4c8081dd86c6aa96984b1d18b26 100644 (file)
@@ -946,6 +946,21 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
 #endif
     }
 
+    {
+        RT_START_TEST(Attributes)
+
+        wxPGProperty* prop = pgman->GetProperty(wxT("StringProperty"));
+        prop->SetAttribute(wxT("Dummy Attribute"), (long)15);
+
+        if ( prop->GetAttribute(wxT("Dummy Attribute")).GetLong() != 15 )
+            RT_FAILURE();
+
+        prop->SetAttribute(wxT("Dummy Attribute"), wxVariant());
+
+        if ( !prop->GetAttribute(wxT("Dummy Attribute")).IsNull() )
+            RT_FAILURE();
+    }
+
     {
         wxPropertyGridPage* page1;
         wxPropertyGridPage* page2;
index c083039124381245a8f06a4e347a86d67af6343a..980f915cb116a109d3a7980bb66c06cb7815ec83 100644 (file)
@@ -2093,12 +2093,23 @@ void wxPGAttributeStorage::Set( const wxString& name, const wxVariant& value )
     // Free old, if any
     wxPGHashMapS2P::iterator it = m_map.find(name);
     if ( it != m_map.end() )
+    {
         ((wxVariantData*)it->second)->DecRef();
 
+        if ( !data )
+        {
+            // If Null variant, just remove from set
+            m_map.erase(it);
+            return;
+        }
+    }
+
     if ( data )
+    {
         data->IncRef();
 
-    m_map[name] = data;
+        m_map[name] = data;
+    }
 }
 
 #endif  // wxUSE_PROPGRID