Make QVariant conversion for JS null type symmetric
authorKent Hansen <kent.hansen@nokia.com>
Thu, 15 Mar 2012 09:15:53 +0000 (10:15 +0100)
committerQt by Nokia <qt-info@nokia.com>
Tue, 20 Mar 2012 05:49:30 +0000 (06:49 +0100)
commitd96d89c63c28f81f9c17666ed66222f523571f03
tree085e7cbd6fe9f134d46ad00433907ed7abc35893
parentd38e9e413ce0c9ee636ea0b4aa722668ad54d1ae
Make QVariant conversion for JS null type symmetric

If you pass (void*)0 to QJSEngine::toScriptValue(), or you pass a
QVariant of type QMetaType::VoidStar containing a 0 value, you get
back a QJSValue of type null (isNull() returns true); that's fine.

However, if you called QJSValue::toVariant() on a JS null value, you
would get back an invalid QVariant. The expected result is a
QVariant of type QMetaType::VoidStar containing a 0 value. This
makes the conversion of the JS null type symmetric and avoids loss
of data.

Change-Id: Ifa6e788152118f80adf9c2d7be1283f053b44294
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
src/qml/qml/v8/qjsvalue.cpp
src/qml/qml/v8/qjsvalue_impl_p.h
src/qml/qml/v8/qv8engine.cpp
tests/auto/qml/qjsengine/tst_qjsengine.cpp
tests/auto/qml/qjsvalue/tst_qjsvalue.cpp