From 03192f749c14ffdde24d3e1585fadf98f9750938 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Thu, 5 Jul 2012 11:53:18 +1000 Subject: [PATCH] Don't provide typehint in QQmlExpression::evaluate() Previously, the result returned by QQmlExpression::evaluate() was converted from the actual JavaScript result with a default typehint of QList. This commit removes that typehint so that the engine's conversion code will choose the most appropriate return type for the result JavaScript value, instead. Task-number: QTBUG-17082 Change-Id: I368a018b235e9e001b1b92db3699de377748b74f Reviewed-by: Michael Brasser --- src/qml/qml/qqmlexpression.cpp | 2 +- .../tst_qqmlenginedebugservice.cpp | 4 ++-- .../auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp index 8c24c4a..2ab412b 100644 --- a/src/qml/qml/qqmlexpression.cpp +++ b/src/qml/qml/qqmlexpression.cpp @@ -378,7 +378,7 @@ QVariant QQmlExpressionPrivate::value(bool *isUndefined) v8::HandleScope handle_scope; v8::Context::Scope context_scope(ep->v8engine()->context()); v8::Local result = v8value(isUndefined); - rv = ep->v8engine()->toVariant(result, qMetaTypeId >()); + rv = ep->v8engine()->toVariant(result, -1); } ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete. diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index f0e3d95..3ecc0d6 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -858,7 +858,7 @@ void tst_QQmlEngineDebugService::queryExpressionResult_data() QTest::newRow("blueRect.width") << "blueRect.width" << qVariantFromValue(500); QTest::newRow("bad expr") << "aeaef" << qVariantFromValue(QString("")); QTest::newRow("QObject*") << "varObj" << qVariantFromValue(QString("")); - QTest::newRow("list of QObject*") << "varObjList" << qVariantFromValue(QString("")); + QTest::newRow("list of QObject*") << "varObjList" << qVariantFromValue(QVariantList() << QVariant(QString(""))); QVariantMap map; map.insert(QLatin1String("rect"), QVariant(QLatin1String(""))); QTest::newRow("varObjMap") << "varObjMap" << qVariantFromValue(map); @@ -906,7 +906,7 @@ void tst_QQmlEngineDebugService::queryExpressionResultBC_data() QTest::newRow("blueRect.width") << "blueRect.width" << qVariantFromValue(500); QTest::newRow("bad expr") << "aeaef" << qVariantFromValue(QString("")); QTest::newRow("QObject*") << "varObj" << qVariantFromValue(QString("")); - QTest::newRow("list of QObject*") << "varObjList" << qVariantFromValue(QString("")); + QTest::newRow("list of QObject*") << "varObjList" << qVariantFromValue(QVariantList() << QVariant(QString(""))); QVariantMap map; map.insert(QLatin1String("rect"), QVariant(QLatin1String(""))); QTest::newRow("varObjMap") << "varObjMap" << qVariantFromValue(map); diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 66ae27e..aaa6d36 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -660,13 +660,13 @@ void tst_qqmlecmascript::arrayExpressions() MyExpression expr(&context, "[a, b, c, 10]"); QVariant result = expr.evaluate(); - QCOMPARE(result.userType(), qMetaTypeId >()); - QList list = qvariant_cast >(result); + QCOMPARE(result.userType(), qMetaTypeId()); + QVariantList list = qvariant_cast(result); QCOMPARE(list.count(), 4); - QCOMPARE(list.at(0), &obj1); - QCOMPARE(list.at(1), &obj2); - QCOMPARE(list.at(2), &obj3); - QCOMPARE(list.at(3), (QObject *)0); + QCOMPARE(list.at(0).value(), &obj1); + QCOMPARE(list.at(1).value(), &obj2); + QCOMPARE(list.at(2).value(), &obj3); + QCOMPARE(list.at(3).value(), 10); } // Tests that modifying a context property will reevaluate expressions -- 1.7.2.5