User should no longer be able to modify disabled or read only child properties by editing their parent (wxPG sf bug #2181860)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56475 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1107,7 +1107,7 @@ public:
|
|||||||
@return
|
@return
|
||||||
true if value was changed.
|
true if value was changed.
|
||||||
*/
|
*/
|
||||||
bool SetValueFromString( const wxString& text, int flags = 0 );
|
bool SetValueFromString( const wxString& text, int flags = wxPG_PROGRAMMATIC_VALUE );
|
||||||
|
|
||||||
/** Converts integer to a value, and if succesful, calls SetValue() on it.
|
/** Converts integer to a value, and if succesful, calls SetValue() on it.
|
||||||
Default behavior is to do nothing.
|
Default behavior is to do nothing.
|
||||||
|
@@ -405,7 +405,10 @@ enum wxPG_MISC_ARG_FLAGS
|
|||||||
|
|
||||||
// ValueToString() called from GetValueAsString()
|
// ValueToString() called from GetValueAsString()
|
||||||
// (guarantees that input wxVariant value is current own value)
|
// (guarantees that input wxVariant value is current own value)
|
||||||
wxPG_VALUE_IS_CURRENT = 0x00000040
|
wxPG_VALUE_IS_CURRENT = 0x00000040,
|
||||||
|
|
||||||
|
// Value is being set programmatically (ie. not by user)
|
||||||
|
wxPG_PROGRAMMATIC_VALUE = 0x00000080
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
@@ -881,7 +881,7 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
|
|||||||
wxVariantList temp_list;
|
wxVariantList temp_list;
|
||||||
wxVariant list(temp_list);
|
wxVariant list(temp_list);
|
||||||
|
|
||||||
int propagatedFlags = argFlags & wxPG_REPORT_ERROR;
|
int propagatedFlags = argFlags & (wxPG_REPORT_ERROR|wxPG_PROGRAMMATIC_VALUE);
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
bool debug_print = false;
|
bool debug_print = false;
|
||||||
@@ -914,41 +914,45 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
|
|||||||
if ( !addOnlyIfNotEmpty || len > 0 )
|
if ( !addOnlyIfNotEmpty || len > 0 )
|
||||||
{
|
{
|
||||||
const wxPGProperty* child = Item(curChild);
|
const wxPGProperty* child = Item(curChild);
|
||||||
|
wxVariant variant(child->GetValue());
|
||||||
|
variant.SetName(child->GetBaseName());
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
if ( debug_print )
|
if ( debug_print )
|
||||||
wxLogDebug(wxT("token = '%s', child = %s"),token.c_str(),child->GetLabel().c_str());
|
wxLogDebug(wxT("token = '%s', child = %s"),token.c_str(),child->GetLabel().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( len > 0 )
|
// Add only if editable or setting programmatically
|
||||||
|
if ( (argFlags & wxPG_PROGRAMMATIC_VALUE) ||
|
||||||
|
!child->HasFlag(wxPG_PROP_DISABLED|wxPG_PROP_READONLY) )
|
||||||
{
|
{
|
||||||
bool wasUnspecified = child->IsValueUnspecified();
|
if ( len > 0 )
|
||||||
|
|
||||||
wxVariant variant(child->GetValueRef());
|
|
||||||
if ( child->StringToValue(variant, token, propagatedFlags|wxPG_COMPOSITE_FRAGMENT) )
|
|
||||||
{
|
{
|
||||||
variant.SetName(child->GetBaseName());
|
bool wasUnspecified = child->IsValueUnspecified();
|
||||||
|
|
||||||
// Clear unspecified flag only if OnSetValue() didn't
|
if ( child->StringToValue(variant, token, propagatedFlags|wxPG_COMPOSITE_FRAGMENT) )
|
||||||
// affect it.
|
|
||||||
if ( child->IsValueUnspecified() &&
|
|
||||||
(wasUnspecified || !UsesAutoUnspecified()) )
|
|
||||||
{
|
{
|
||||||
variant = child->GetDefaultValue();
|
// Clear unspecified flag only if OnSetValue() didn't
|
||||||
|
// affect it.
|
||||||
|
if ( child->IsValueUnspecified() &&
|
||||||
|
(wasUnspecified || !UsesAutoUnspecified()) )
|
||||||
|
{
|
||||||
|
variant = child->GetDefaultValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
list.Append(variant);
|
||||||
|
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Empty, becomes unspecified
|
||||||
|
variant.MakeNull();
|
||||||
list.Append(variant);
|
list.Append(variant);
|
||||||
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Empty, becomes unspecified
|
|
||||||
wxVariant variant2;
|
|
||||||
variant2.SetName(child->GetBaseName());
|
|
||||||
list.Append(variant2);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
curChild++;
|
curChild++;
|
||||||
if ( curChild >= iMax )
|
if ( curChild >= iMax )
|
||||||
@@ -997,17 +1001,22 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
|
|||||||
|
|
||||||
wxVariant oldChildValue = child->GetValue();
|
wxVariant oldChildValue = child->GetValue();
|
||||||
wxVariant variant(oldChildValue);
|
wxVariant variant(oldChildValue);
|
||||||
bool stvRes = child->StringToValue( variant, token, propagatedFlags );
|
|
||||||
if ( stvRes || (variant != oldChildValue) )
|
if ( (argFlags & wxPG_PROGRAMMATIC_VALUE) ||
|
||||||
|
!child->HasFlag(wxPG_PROP_DISABLED|wxPG_PROP_READONLY) )
|
||||||
{
|
{
|
||||||
if ( stvRes )
|
bool stvRes = child->StringToValue( variant, token, propagatedFlags );
|
||||||
|
if ( stvRes || (variant != oldChildValue) )
|
||||||
|
{
|
||||||
|
if ( stvRes )
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Failed, becomes unspecified
|
||||||
|
variant.MakeNull();
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Failed, becomes unspecified
|
|
||||||
variant.MakeNull();
|
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
variant.SetName(child->GetBaseName());
|
variant.SetName(child->GetBaseName());
|
||||||
|
@@ -5855,7 +5855,8 @@ wxPGProperty* wxPropertyGridPopulator::Add( const wxString& propClass,
|
|||||||
m_state->DoInsert(parent, -1, property);
|
m_state->DoInsert(parent, -1, property);
|
||||||
|
|
||||||
if ( propValue )
|
if ( propValue )
|
||||||
property->SetValueFromString( *propValue, wxPG_FULL_VALUE );
|
property->SetValueFromString( *propValue, wxPG_FULL_VALUE|
|
||||||
|
wxPG_PROGRAMMATIC_VALUE );
|
||||||
|
|
||||||
return property;
|
return property;
|
||||||
}
|
}
|
||||||
|
@@ -1100,7 +1100,7 @@ bool wxPropertyGridPageState::DoSetPropertyValueString( wxPGProperty* p, const w
|
|||||||
{
|
{
|
||||||
if ( p )
|
if ( p )
|
||||||
{
|
{
|
||||||
int flags = wxPG_REPORT_ERROR|wxPG_FULL_VALUE;
|
int flags = wxPG_REPORT_ERROR|wxPG_FULL_VALUE|wxPG_PROGRAMMATIC_VALUE;
|
||||||
|
|
||||||
wxVariant variant = p->GetValueRef();
|
wxVariant variant = p->GetValueRef();
|
||||||
bool res;
|
bool res;
|
||||||
|
Reference in New Issue
Block a user