From d94e807cfc24eb4990211f59ae0b74de83818548 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 17 May 2014 12:29:26 +0000 Subject: [PATCH] Fix querying the value of wxEnumProperty in wxPropertyGridEditor. Doing this changed the internal state of the control and resulted in the choice not being updated. Fix this by using wxPG_PROPERTY_SPECIFIC. Closes #15449. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76557 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/propgrid/editors.cpp | 4 ++-- src/propgrid/props.cpp | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/propgrid/editors.cpp b/src/propgrid/editors.cpp index f805f504c7..eeb467b366 100644 --- a/src/propgrid/editors.cpp +++ b/src/propgrid/editors.cpp @@ -1168,7 +1168,7 @@ bool wxPGChoiceEditor::GetValueFromControl( wxVariant& variant, wxPGProperty* pr property->IsValueUnspecified() ) { - return property->IntToValue( variant, index, 0 ); + return property->IntToValue(variant, index, wxPG_PROPERTY_SPECIFIC); } return false; } @@ -1691,7 +1691,7 @@ bool wxPGCheckBoxEditor::GetValueFromControl( wxVariant& variant, wxPGProperty* property->IsValueUnspecified() ) { - return property->IntToValue(variant, index, 0); + return property->IntToValue(variant, index, wxPG_PROPERTY_SPECIFIC); } return false; } diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index b64764b206..fc939277e4 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -1305,22 +1305,27 @@ bool wxEnumProperty::ValueFromInt_( wxVariant& variant, int intVal, int argFlags { // If wxPG_FULL_VALUE is *not* in argFlags, then intVal is index from combo box. // - ms_nextIndex = -2; + int setAsNextIndex = -2; if ( argFlags & wxPG_FULL_VALUE ) { - ms_nextIndex = GetIndexForValue( intVal ); + setAsNextIndex = GetIndexForValue( intVal ); } else { if ( intVal != GetIndex() ) { - ms_nextIndex = intVal; + setAsNextIndex = intVal; } } - if ( ms_nextIndex != -2 ) + if ( setAsNextIndex != -2 ) { + // If wxPG_PROPERTY_SPECIFIC is set, then this is done for + // validation or fetching a data purposes only, and index must not be changed. + if ( !(argFlags & wxPG_PROPERTY_SPECIFIC) ) + ms_nextIndex = setAsNextIndex; + if ( !(argFlags & wxPG_FULL_VALUE) ) intVal = m_choices.GetValue(intVal);