I’m working on a project that makes heavy use of passing Variants (and VariantVectors) in and out of functions. Everything was going ok until I started targeting Emscripten (which is an essential target). I have a number of questions, but here is a very simple case that has confounded me:
Ok, so I want to construct a Variant of type Double and double check it with some console output:
Variant varA = Variant(1.0);
URHO3D_LOGINFO("varA value: " + varA.ToString() + ", type: " + varA.GetTypeName(varA.GetType()));
Running this in Chrome, gives the expected results:
So far so good. Now, I create two variants, one after the other:
Variant varA = Variant(1.0);
Variant varB = Variant(2.0);
URHO3D_LOGINFO("varA value: " + varA.ToString() + ", type: " + varA.GetTypeName(varA.GetType()));
URHO3D_LOGINFO("varB value: " + varB.ToString() + ", type: " + varB.GetTypeName(varB.GetType()));
This is gives us the following console output:
Notice that the second variant is now not being create correctly. Or at least, the output is not correct. This seems very wrong.
Ok, one more. I create the two variants and push them to a VariantVector and display the results:
Variant varA = Variant(1.0);
Variant varB = Variant(2.0);
URHO3D_LOGINFO("varA value: " + varA.ToString() + ", type: " + varA.GetTypeName(varA.GetType()));
URHO3D_LOGINFO("varB value: " + varB.ToString() + ", type: " + varB.GetTypeName(varB.GetType()));
VariantVector varVector;
varVector.Push(varA); varVector.Push(varB);
URHO3D_LOGINFO("vec value at 0: " + varVector[0].ToString() + ", type: " + varVector[0].GetTypeName(varVector[0].GetType()));
URHO3D_LOGINFO("vec value at 1: " + varVector[1].ToString() + ", type: " + varVector[1].GetTypeName(varVector[1].GetType()));
And here is the result:
Notice that now, the first variant is not correct.
Please help!