Browse Source

Squashed commit of the following:

commit b21e10951ff9535e80f2b222336c5f88e11e63af
Author: Nick Royer <[email protected]>
Date:   Tue Dec 22 22:00:14 2015 -0600

    Added Context parameter in JSONValue::SetVariantVector to fix
    ResourceRef bug

commit 297f8bcde3e24ad67e5fce56b7d0bab6fb616432
Merge: 5a150b2 2802146
Author: Nick Royer <[email protected]>
Date:   Tue Dec 22 21:35:50 2015 -0600

    Merge branch 'JSONValueFix' of https://github.com/hjmediastudios/Urho3D into JSONValueFix

commit 5a150b298e860c81fa17e9f0c6906b493477f97b
Author: Nick Royer <[email protected]>
Date:   Tue Dec 22 21:35:23 2015 -0600

    Fixed bug caused by attempting to set a JSONValue to a VariantVector;
    previous behavior attempted to assign values to indices beyond the size
    of the JSONValue's array storage.

commit 2802146005849314d8d3662468ec324ae8b321b3
Merge: 65c8125 e1647d1
Author: NickRoyer <[email protected]>
Date:   Tue Dec 22 21:29:06 2015 -0600

    Merge pull request #2 from urho3d/master

    Make Urho3D_universal custom target as one of the default target.
Lasse Öörni 10 years ago
parent
commit
48ab1f3bda
1 changed files with 7 additions and 2 deletions
  1. 7 2
      Source/Urho3D/Resource/JSONValue.cpp

+ 7 - 2
Source/Urho3D/Resource/JSONValue.cpp

@@ -559,8 +559,13 @@ VariantMap JSONValue::GetVariantMap() const
 void JSONValue::SetVariantVector(const VariantVector& variantVector, Context* context)
 void JSONValue::SetVariantVector(const VariantVector& variantVector, Context* context)
 {
 {
     SetType(JSON_ARRAY);
     SetType(JSON_ARRAY);
+    arrayValue_->Reserve(variantVector.Size());
     for (unsigned i = 0; i < variantVector.Size(); ++i)
     for (unsigned i = 0; i < variantVector.Size(); ++i)
-        (*this)[i].SetVariant(variantVector[i]);
+    {
+        JSONValue val;
+        val.SetVariant(variantVector[i], context);
+        arrayValue_->Push(val);
+    }
 }
 }
 
 
 VariantVector JSONValue::GetVariantVector() const
 VariantVector JSONValue::GetVariantVector() const
@@ -581,4 +586,4 @@ VariantVector JSONValue::GetVariantVector() const
     return variantVector;
     return variantVector;
 }
 }
 
 
-}
+}