Unwrap QJSValue from QVariant in QV8Engine::fromVariant
authorJędrzej Nowacki <jedrzej.nowacki@nokia.com>
Fri, 16 Sep 2011 12:06:02 +0000 (14:06 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 19 Sep 2011 11:25:39 +0000 (13:25 +0200)
commit8de9a07c654492a60726e84332bba43cc7b81dbd
tree9de928d934c301925fe6fe1e15edf851f73b008b
parentc970d47d4ec8bed85acc313e22ddb8bbba55618e
Unwrap QJSValue from QVariant in QV8Engine::fromVariant

When QML tries to unwrap real value from a QVariant and
the value is a QJSValue instance, then no conversion is needed,
QJSValue already contains a v8 handle.

This patch, for example, solves a problem of emitting QJSValue
instance in a signal that has QVariant as an argument. The QJSValue
can be unwrapped and used as a normal JS value in a connected slot.
This feature may be used also in a plugin model that stores QJSValues
internally. Then the model in data() function can return a QJSValue
which would be understood by QML.

Change-Id: I1d5ede40ce2637123b09839fd848b27ad3af3dda
Reviewed-on: http://codereview.qt-project.org/4451
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
src/declarative/qml/v8/qv8engine.cpp
tests/auto/declarative/qdeclarativeecmascript/data/signalWithJSValueInVariant.qml [new file with mode: 0644]
tests/auto/declarative/qdeclarativeecmascript/testtypes.h
tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp