Fixes in wxPGProperty::StringToValue(): Prevent it-- from iterating into negative index; only really mark/add nested children as changed if child's StringToValue() returned true

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57836 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Jaakko Salli
2009-01-04 19:05:44 +00:00
parent ae82388e3c
commit a64a1bf767

View File

@@ -972,6 +972,11 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
for ( ;; ) for ( ;; )
{ {
// How many units we iterate string forward at the end of loop?
// We need to keep track of this or risk going to negative
// with it-- operation.
unsigned int strPosIncrement = 1;
if ( tokenStart != 0xFFFFFF ) if ( tokenStart != 0xFFFFFF )
{ {
// Token is running // Token is running
@@ -1077,23 +1082,23 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
if ( (argFlags & wxPG_PROGRAMMATIC_VALUE) || if ( (argFlags & wxPG_PROGRAMMATIC_VALUE) ||
!child->HasFlag(wxPG_PROP_DISABLED|wxPG_PROP_READONLY) ) !child->HasFlag(wxPG_PROP_DISABLED|wxPG_PROP_READONLY) )
{ {
bool stvRes = child->StringToValue( variant, token, propagatedFlags ); wxString childName = child->GetBaseName();
bool stvRes = child->StringToValue( variant, token,
propagatedFlags );
if ( stvRes || (variant != oldChildValue) ) if ( stvRes || (variant != oldChildValue) )
{ {
if ( stvRes ) variant.SetName(childName);
changed = true; list.Append(variant);
changed = true;
} }
else else
{ {
// Failed, becomes unspecified // No changes...
variant.MakeNull();
changed = true;
} }
} }
variant.SetName(child->GetBaseName());
list.Append(variant);
curChild++; curChild++;
if ( curChild >= iMax ) if ( curChild >= iMax )
break; break;
@@ -1107,10 +1112,7 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
tokenStart = pos; tokenStart = pos;
if ( a == delimeter ) if ( a == delimeter )
{ strPosIncrement -= 1;
pos--;
--it;
}
} }
} }
} }
@@ -1118,7 +1120,8 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
if ( a == 0 ) if ( a == 0 )
break; break;
++it; it += strPosIncrement;
if ( it != text.end() ) if ( it != text.end() )
{ {
a = *it; a = *it;
@@ -1127,7 +1130,8 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
{ {
a = 0; a = 0;
} }
pos++;
pos += strPosIncrement;
} }
if ( changed ) if ( changed )