From 26b22ae371c4ba3cfc35deb0f72b4288081b54fd Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Fri, 26 Feb 2010 15:45:30 +0000 Subject: [PATCH] Must clear property selection in wxPGProperty::SetChoices() or risk a crash git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63562 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/propgrid/property.h | 7 ++++--- interface/wx/propgrid/property.h | 5 +++-- src/propgrid/property.cpp | 6 ++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h index 0e34bcf2ed..7057e9c2f4 100644 --- a/include/wx/propgrid/property.h +++ b/include/wx/propgrid/property.h @@ -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 ); diff --git a/interface/wx/propgrid/property.h b/interface/wx/propgrid/property.h index 95493ad7b4..bf1c1caf62 100644 --- a/interface/wx/propgrid/property.h +++ b/interface/wx/propgrid/property.h @@ -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 ); diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index 1dd2855431..4e82bcc338 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -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); { -- 2.45.2