From 285bedc5e54e0d44d4f6490efe3d9ea8b974e910 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Fri, 19 Apr 2019 20:51:17 +0200 Subject: [PATCH] Always redraw wxPGProperty after changing its attribute Because changing some attributes of the property affects the format of displayed value so the property has to be refreshed whether its attribute is set through wxPGProperty::SetAttribute() or wxPropertyGridInterface::SetPropertyAttribute(). Closes #18388. --- src/propgrid/property.cpp | 17 +++++++++++------ src/propgrid/propgridiface.cpp | 8 +------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index 700eef79ac..9cc04632b3 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -1855,14 +1855,19 @@ bool wxPGProperty::DoSetAttribute( const wxString& WXUNUSED(name), wxVariant& WX void wxPGProperty::SetAttribute( const wxString& name, wxVariant value ) { - if ( DoSetAttribute( name, value ) ) + if ( !DoSetAttribute(name, value) || !wxPGGlobalVars->HasExtraStyle(wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES) ) { - // Support working without grid, when possible - if ( wxPGGlobalVars->HasExtraStyle( wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES ) ) - return; + m_attributes.Set(name, value); + } + // Because changing some attributes (like wxPG_FLOAT_PRECISION, wxPG_UINT_BASE, + // wxPG_UINT_PREFIX, wxPG_ATTR_UNITS) affect displayed form of the property value + // so we have to redraw property to be sure that displayed value is in sync + // with current attributes. + wxPropertyGrid* pg = GetGridIfDisplayed(); + if ( pg ) + { + pg->RefreshProperty(this); } - - m_attributes.Set( name, value ); } void wxPGProperty::SetAttributes( const wxPGAttributeStorage& attributes ) diff --git a/src/propgrid/propgridiface.cpp b/src/propgrid/propgridiface.cpp index 1b7f3c802b..2d294cd0d5 100644 --- a/src/propgrid/propgridiface.cpp +++ b/src/propgrid/propgridiface.cpp @@ -452,13 +452,7 @@ void wxPropertyGridInterface::DoSetPropertyAttribute( wxPGPropArg id, const wxSt { wxPG_PROP_ARG_CALL_PROLOG() - p->SetAttribute( name, value ); - // If property is attached to the property grid - // then refresh the view. - if( p->GetParentState() ) - { - RefreshProperty( p ); - } + p->SetAttribute( name, value ); // property is also refreshed here if ( argFlags & wxPG_RECURSE ) {