From: Kent Hansen Date: Fri, 11 Nov 2011 08:39:15 +0000 (+0100) Subject: Add autotest for qml/v8 optimization bug X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=92660b13bb138d219f49ea203fa5e5aed9de74cb;p=konrad%2Fqtdeclarative.git Add autotest for qml/v8 optimization bug After a function that accesses a qml context property was inlined, calls to global functions would fail with "TypeError: Illegal invocation". Fixed in qtbase's v8. Task-number: QTBUG-22679 Change-Id: Id6e2604e5151585febfe1b667869dc3b1fad6e5e Reviewed-by: Aaron Kennedy --- diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22679.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22679.qml new file mode 100644 index 0000000..b38a84b --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22679.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +QtObject { + function accessContextProperty() { + for (var i = 0; i < contextProp.stringProperty.length; ++i) ; + } + + Component.onCompleted: { + for (var i = 0; i < 1000; ++i) + accessContextProperty(); + // Shouldn't cause "Illegal invocation" error. + gc(); + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index e784ffb..7d9819b 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -223,6 +223,7 @@ private slots: void invokableObjectArg(); void invokableObjectRet(); void qtbug_20344(); + void qtbug_22679(); void revisionErrors(); void revision(); @@ -5148,6 +5149,22 @@ void tst_qdeclarativeecmascript::deleteWhileBindingRunning() delete object; } +void tst_qdeclarativeecmascript::qtbug_22679() +{ + MyQmlObject object; + object.setStringProperty(QLatin1String("Please work correctly")); + engine.rootContext()->setContextProperty("contextProp", &object); + + QDeclarativeComponent component(&engine, TEST_FILE("qtbug_22679.qml")); + qRegisterMetaType >("QList"); + QSignalSpy warningsSpy(&engine, SIGNAL(warnings(QList))); + + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(warningsSpy.count(), 0); + delete o; +} + QTEST_MAIN(tst_qdeclarativeecmascript) #include "tst_qdeclarativeecmascript.moc"