]> git.saurik.com Git - wxWidgets.git/commitdiff
Must clear property selection in wxPGProperty::SetChoices() or risk a crash
authorJaakko Salli <jaakko.salli@dnainternet.net>
Fri, 26 Feb 2010 15:45:30 +0000 (15:45 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Fri, 26 Feb 2010 15:45:30 +0000 (15:45 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63562 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/propgrid/property.h
interface/wx/propgrid/property.h
src/propgrid/property.cpp

index 0e34bcf2ed0702cea156c237bfc880cbc8014067..7057e9c2f44ddf8959e788ca2ccd39bb51a39915 100644 (file)
@@ -2109,10 +2109,11 @@ public:
     */
     wxClientData *GetClientObject() const { return m_clientObject; }
 
-    /** Sets new set of choices for property.
+    /**
+        Sets new set of choices for the property.
 
-        @remarks
-        This operation clears the property value.
+        @remarks This operation deselects the property and clears its
+                 value.
     */
     bool SetChoices( wxPGChoices& choices );
 
index 95493ad7b4b44f7cb1a77f712afe1dff3ad3a989..bf1c1caf62735f0b28dbf85b43e69247446a2665 100644 (file)
@@ -1364,9 +1364,10 @@ public:
     void SetCell( int column, const wxPGCell& cell );
 
     /**
-        Sets new set of choices for property.
+        Sets new set of choices for the property.
 
-        @remarks This operation clears the property value.
+        @remarks This operation deselects the property and clears its
+                 value.
     */
     bool SetChoices( wxPGChoices& choices );
 
index 1dd2855431b916dc9346f8e8b5131ffcece032eb..4e82bcc338f0bddbd27b241554d95a7111645f1f 100644 (file)
@@ -1911,6 +1911,12 @@ void wxPGProperty::SetChoiceSelection( int newValue )
 
 bool wxPGProperty::SetChoices( wxPGChoices& choices )
 {
+    // Property must be de-selected first (otherwise choices in
+    // the control would be de-synced with true choices)
+    wxPropertyGrid* pg = GetGrid();
+    if ( pg && pg->GetSelection() == this )
+        pg->ClearSelection();
+
     m_choices.Assign(choices);
 
     {