Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Not Evaluated
-
Resolution: Done
-
Affects Version/s: 5.0.0
-
Fix Version/s: 5.0.0 Beta 1
-
Component/s: QML: Declarative and Javascript Engine
-
Labels:None
-
Commits:9ee6bb0e14d968647350683eafbe80eed7a27058
Description
I have a C++ defined property of type QJSValue, and use it in the following QML:
Item { Foo { id: literal foo: [ { latitude: 5, longitude: 6 } ] } property variant coord1: QtLocation.coordinate(5, 6) Foo { id: prop foo: [ coord1 ] } Foo { id: func foo: [ QtLocation.coordinate(5, 6) ] } }
Both the literal and prop objects are parsed as expected. For the func object in the foo setter I have verified that the value passed in is correct. I can use QJSValue::toString() to print out the correct value of each item in the array. However, QJSValue::toVariant() returns a QVariant containing a QVariantMap.
Changing the returned value of QJSValuePrivate::toVariant() from
return m_engine->variantFromJS(m_value);
to
return m_engine->toVariant(m_value, -1);
as suggested seems to fix the issue in this case.