]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixes in wxPGProperty::StringToValue(): Prevent it-- from iterating into negative...
authorJaakko Salli <jaakko.salli@dnainternet.net>
Sun, 4 Jan 2009 19:05:44 +0000 (19:05 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Sun, 4 Jan 2009 19:05:44 +0000 (19:05 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57836 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/propgrid/property.cpp

index ec75b88fcd8d3a9939e92c9fae05827662818364..1663eda6f9c24106576342ab22874327c69bd8a8 100644 (file)
@@ -972,6 +972,11 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
 
     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 )
         {
             // Token is running
@@ -1077,23 +1082,23 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
                     if ( (argFlags & wxPG_PROGRAMMATIC_VALUE) ||
                          !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 )
-                                changed = true;
+                            variant.SetName(childName);
+                            list.Append(variant);
+
+                            changed = true;
                         }
                         else
                         {
-                            // Failed, becomes unspecified
-                            variant.MakeNull();
-                            changed = true;
+                            // No changes...
                         }
                     }
 
-                    variant.SetName(child->GetBaseName());
-                    list.Append(variant);
-
                     curChild++;
                     if ( curChild >= iMax )
                         break;
@@ -1107,10 +1112,7 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
                     tokenStart = pos;
 
                     if ( a == delimeter )
-                    {
-                        pos--;
-                        --it;
-                    }
+                        strPosIncrement -= 1;
                 }
             }
         }
@@ -1118,7 +1120,8 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
         if ( a == 0 )
             break;
 
-        ++it;
+        it += strPosIncrement;
+
         if ( it != text.end() )
         {
             a = *it;
@@ -1127,7 +1130,8 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
         {
             a = 0;
         }
-        pos++;
+
+        pos += strPosIncrement;
     }
 
     if ( changed )