From fa9fcf2fb259b1b3eb09e0c853075ca328e930c5 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Mon, 12 Mar 2012 11:54:11 +1000 Subject: Fix crash when writing property after engine deletion Previously, the engine pointer stored in a QQmlProperty could be stale due to engine deletion. This commit ensures we guard that pointer. Also reverts cbb7f8b10e99fad675839d7625d3236ed67b3e01 Task-number: QTBUG-24734 Change-Id: I5349c51fbd19fa46a8710280173c1d224358b96e Reviewed-by: Michael Brasser --- tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index 13ea1abd73..ae300900c9 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -1553,8 +1553,6 @@ void tst_qqmlproperty::crashOnValueProperty() delete engine; engine = 0; - QSKIP("QTBUG-24734: test accesses deleted QML engine from QQmlProperty::propertyTypeName()"); - QCOMPARE(p.propertyTypeName(), "int"); QCOMPARE(p.read(), QVariant(10)); p.write(QVariant(20)); -- cgit v1.2.3 From 69a1bf164822fe50ced9db1429446e7e84357c1b Mon Sep 17 00:00:00 2001 From: Aurindam Jana Date: Mon, 12 Mar 2012 10:19:05 +0100 Subject: QmlDebugging: Modify test JSDebug test cases Add signals that are emitted on debugger responses for flaky auto tests. Change-Id: Ic59f559083b2b19fb8eec920dcb76f23125639a8 Reviewed-by: Kai Koehne --- tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp index 9cd021d5e9..f4a9a4add7 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp +++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp @@ -303,6 +303,8 @@ signals: void breakAfterCompileRequested(); void result(); void stopped(); + void scriptsResult(); + void evaluateResult(); private: void sendMessage(const QByteArray &); @@ -939,6 +941,12 @@ void QJSDebugClient::messageReceived(const QByteArray &data) } else { // DO NOTHING } + //Emit separate signals for scripts ane evaluate + //as the associated test cases are flaky + if (debugCommand == "scripts") + emit scriptsResult(); + if (debugCommand == "evaluate") + emit evaluateResult(); } else if (type == QLatin1String(EVENT)) { QString event(value.value(QLatin1String(EVENT)).toString()); @@ -1685,8 +1693,8 @@ void tst_QQmlDebugJS::evaluateInGlobalScope() QVERIFY(init()); client->connect(); - client->evaluate(QLatin1String("print('Hello World')"), true); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + client->evaluate(QLatin1String("console.log('Hello World')"), true); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(evaluateResult()))); //Verify the value of 'print' QString jsonString(client->response); @@ -1720,7 +1728,7 @@ void tst_QQmlDebugJS::evaluateInLocalScope() int frameIndex = body.value("index").toInt(); client->evaluate(QLatin1String("root.a"), frameIndex); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(evaluateResult()))); //Verify the value of 'timer.interval' jsonString = client->response; @@ -1759,7 +1767,7 @@ void tst_QQmlDebugJS::getScripts() client->connect(); client->scripts(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(scriptsResult()))); QString jsonString(client->response); QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); -- cgit v1.2.3 From 665f860d9aaccd222c7fa8e309f087be35768022 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 8 Mar 2012 14:41:40 +1000 Subject: Support module api objects in v4. Change-Id: I72911a2c8e0a8613e53861da7b38312e51bf57da Reviewed-by: Roberto Raggi --- .../data/moduleapi/qobjectModuleApiWriting.qml | 8 ++++++-- tests/auto/qml/qqmlecmascript/testtypes.cpp | 1 + tests/auto/qml/qqmlecmascript/testtypes.h | 8 +++++++- tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 12 ++++++------ 4 files changed, 20 insertions(+), 9 deletions(-) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml index be647ca57f..e4a68d14ea 100644 --- a/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml +++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml @@ -6,6 +6,7 @@ QtObject { property int secondProperty: 2 property int readOnlyProperty: QtTest.qobjectTestProperty property int writableProperty: QtTest.qobjectTestWritableProperty + property int writableFinalProperty: QtTest.qobjectTestWritableFinalProperty onFirstPropertyChanged: { // In this case, we want to attempt to set the module API property. @@ -16,11 +17,14 @@ QtObject { } onSecondPropertyChanged: { - // In this case, we want to attempt to set the module API property. - // This should succeed, as the module API property is writable. + // In this case, we want to attempt to set the module API properties. + // This should succeed, as the module API properties are writable. if (secondProperty != QtTest.qobjectTestWritableProperty) { QtTest.qobjectTestWritableProperty = secondProperty; // should succeed. } + if (secondProperty != QtTest.qobjectTestWritableFinalProperty) { + QtTest.qobjectTestWritableFinalProperty = secondProperty; // should succeed. + } } } diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp index 78119cb776..64e91fbc95 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.cpp +++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp @@ -140,6 +140,7 @@ static QObject *qobject_api(QQmlEngine *engine, QJSEngine *scriptEngine) testQObjectApi *o = new testQObjectApi(); o->setQObjectTestProperty(20); o->setQObjectTestWritableProperty(50); + o->setQObjectTestWritableFinalProperty(10); return o; } diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index 1d68e8ae13..65b84d66cb 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -978,10 +978,11 @@ class testQObjectApi : public QObject Q_ENUMS(MyEnum) Q_PROPERTY (int qobjectTestProperty READ qobjectTestProperty NOTIFY qobjectTestPropertyChanged) Q_PROPERTY (int qobjectTestWritableProperty READ qobjectTestWritableProperty WRITE setQObjectTestWritableProperty NOTIFY qobjectTestWritablePropertyChanged) + Q_PROPERTY (int qobjectTestWritableFinalProperty READ qobjectTestWritableFinalProperty WRITE setQObjectTestWritableFinalProperty NOTIFY qobjectTestWritableFinalPropertyChanged FINAL) public: testQObjectApi(QObject* parent = 0) - : QObject(parent), m_testProperty(0), m_testWritableProperty(0), m_methodCallCount(0) + : QObject(parent), m_testProperty(0), m_testWritableProperty(0), m_testWritableFinalProperty(0), m_methodCallCount(0) { } @@ -997,13 +998,18 @@ public: int qobjectTestWritableProperty() const { return m_testWritableProperty; } void setQObjectTestWritableProperty(int tp) { m_testWritableProperty = tp; emit qobjectTestWritablePropertyChanged(tp); } + int qobjectTestWritableFinalProperty() const { return m_testWritableFinalProperty; } + void setQObjectTestWritableFinalProperty(int tp) { m_testWritableFinalProperty = tp; emit qobjectTestWritableFinalPropertyChanged(); } + signals: void qobjectTestPropertyChanged(int testProperty); void qobjectTestWritablePropertyChanged(int testWritableProperty); + void qobjectTestWritableFinalPropertyChanged(); private: int m_testProperty; int m_testWritableProperty; + int m_testWritableFinalProperty; int m_methodCallCount; }; diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 5770dc4e03..0631df1759 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -3089,13 +3089,13 @@ void tst_qqmlecmascript::moduleApi_data() QTest::newRow("qobject, writing + readonly constraints") << testFileUrl("moduleapi/qobjectModuleApiWriting.qml") << QString() - << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/qobjectModuleApiWriting.qml").toLocalFile() + QLatin1String(":14: Error: Cannot assign to read-only property \"qobjectTestProperty\""))) - << (QStringList() << "readOnlyProperty" << "writableProperty") - << (QVariantList() << 20 << 50) - << (QStringList() << "firstProperty" << "writableProperty") + << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/qobjectModuleApiWriting.qml").toLocalFile() + QLatin1String(":15: Error: Cannot assign to read-only property \"qobjectTestProperty\""))) + << (QStringList() << "readOnlyProperty" << "writableProperty" << "writableFinalProperty") + << (QVariantList() << 20 << 50 << 10) + << (QStringList() << "firstProperty" << "secondProperty") << (QVariantList() << 30 << 30) - << (QStringList() << "readOnlyProperty" << "writableProperty") - << (QVariantList() << 20 << 30); + << (QStringList() << "readOnlyProperty" << "writableProperty" << "writableFinalProperty") + << (QVariantList() << 20 << 30 << 30); QTest::newRow("script, writing + readonly constraints") << testFileUrl("moduleapi/scriptModuleApiWriting.qml") -- cgit v1.2.3 From b7f3138957ced630aca98ecb63acf873e7d2d103 Mon Sep 17 00:00:00 2001 From: Luis Gabriel Lima Date: Wed, 7 Mar 2012 23:24:18 -0300 Subject: Fix AND expression in v4 The type of the and expressions, e.g. (a && b), were being assigned to the type of the right hand expression (b). As reported in QTBUG-24660, this approach could lead to some unexpected behaviors. Now, when the left and right hand expressions are of different types, the responsability to deal with the and expression is delegated to v8. Task-number: QTBUG-24660 Change-Id: Ic42ebb035e62e2f197c337b2106d00453a99f04c Reviewed-by: Roberto Raggi --- tests/auto/qml/v4/data/logicalAnd.2.qml | 6 ++ tests/auto/qml/v4/data/logicalAnd.3.qml | 8 ++ tests/auto/qml/v4/data/logicalAnd.4.qml | 8 ++ tests/auto/qml/v4/data/logicalAnd.5.qml | 7 ++ tests/auto/qml/v4/data/logicalAnd.6.qml | 9 +++ tests/auto/qml/v4/data/logicalAnd.7.qml | 9 +++ tests/auto/qml/v4/data/logicalAnd.qml | 6 ++ tests/auto/qml/v4/data/nestedLogicalAnd.qml | 14 ++++ tests/auto/qml/v4/tst_v4.cpp | 111 ++++++++++++++++++++++++++++ 9 files changed, 178 insertions(+) create mode 100644 tests/auto/qml/v4/data/logicalAnd.2.qml create mode 100644 tests/auto/qml/v4/data/logicalAnd.3.qml create mode 100644 tests/auto/qml/v4/data/logicalAnd.4.qml create mode 100644 tests/auto/qml/v4/data/logicalAnd.5.qml create mode 100644 tests/auto/qml/v4/data/logicalAnd.6.qml create mode 100644 tests/auto/qml/v4/data/logicalAnd.7.qml create mode 100644 tests/auto/qml/v4/data/logicalAnd.qml create mode 100644 tests/auto/qml/v4/data/nestedLogicalAnd.qml (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/v4/data/logicalAnd.2.qml b/tests/auto/qml/v4/data/logicalAnd.2.qml new file mode 100644 index 0000000000..cc3d75bd90 --- /dev/null +++ b/tests/auto/qml/v4/data/logicalAnd.2.qml @@ -0,0 +1,6 @@ +import Qt.v4 1.0 + +Result { + property string s: "foo" && "bar" + result: s == "bar" +} diff --git a/tests/auto/qml/v4/data/logicalAnd.3.qml b/tests/auto/qml/v4/data/logicalAnd.3.qml new file mode 100644 index 0000000000..6527f05d07 --- /dev/null +++ b/tests/auto/qml/v4/data/logicalAnd.3.qml @@ -0,0 +1,8 @@ +import Qt.v4 1.0 + +Result { + property string s: "" + property bool flag: true + + result: (s && flag) == "" +} diff --git a/tests/auto/qml/v4/data/logicalAnd.4.qml b/tests/auto/qml/v4/data/logicalAnd.4.qml new file mode 100644 index 0000000000..fbcee91699 --- /dev/null +++ b/tests/auto/qml/v4/data/logicalAnd.4.qml @@ -0,0 +1,8 @@ +import Qt.v4 1.0 + +Result { + property string s: "foo" + property bool flag: true + + result: (!flag && s) == false +} diff --git a/tests/auto/qml/v4/data/logicalAnd.5.qml b/tests/auto/qml/v4/data/logicalAnd.5.qml new file mode 100644 index 0000000000..f0698463fe --- /dev/null +++ b/tests/auto/qml/v4/data/logicalAnd.5.qml @@ -0,0 +1,7 @@ +import Qt.v4 1.0 + +Result { + property bool flag: true + + result: (null && flag) == null +} diff --git a/tests/auto/qml/v4/data/logicalAnd.6.qml b/tests/auto/qml/v4/data/logicalAnd.6.qml new file mode 100644 index 0000000000..e98b5c99cd --- /dev/null +++ b/tests/auto/qml/v4/data/logicalAnd.6.qml @@ -0,0 +1,9 @@ +import Qt.v4 1.0 + +Result { + property string s: "" + property bool flag: true + property string subresult: s && flag + + result: subresult === "" +} diff --git a/tests/auto/qml/v4/data/logicalAnd.7.qml b/tests/auto/qml/v4/data/logicalAnd.7.qml new file mode 100644 index 0000000000..0f19d3fb40 --- /dev/null +++ b/tests/auto/qml/v4/data/logicalAnd.7.qml @@ -0,0 +1,9 @@ +import Qt.v4 1.0 + +Result { + property real nan: Number.NaN + property bool flag: true + property real subresult: nan && flag + + result: isNaN(subresult) +} diff --git a/tests/auto/qml/v4/data/logicalAnd.qml b/tests/auto/qml/v4/data/logicalAnd.qml new file mode 100644 index 0000000000..40fc3616c2 --- /dev/null +++ b/tests/auto/qml/v4/data/logicalAnd.qml @@ -0,0 +1,6 @@ +import Qt.v4 1.0 + +Result { + property int a: 10 + result: a == 10 && a == 2 +} diff --git a/tests/auto/qml/v4/data/nestedLogicalAnd.qml b/tests/auto/qml/v4/data/nestedLogicalAnd.qml new file mode 100644 index 0000000000..1358fcea64 --- /dev/null +++ b/tests/auto/qml/v4/data/nestedLogicalAnd.qml @@ -0,0 +1,14 @@ +import Qt.v4 1.0 + +Result { + property bool val1: false + property bool val2: true + property bool val3: false + + property bool b1: (true && true && false) + property bool b2: (true && (false && true)) + property bool b3: ((true && true) && true) + property bool b4: (val1 && (val2 && val3)) ? true : false + + result: !b1 && !b2 && b3 && !b4 +} diff --git a/tests/auto/qml/v4/tst_v4.cpp b/tests/auto/qml/v4/tst_v4.cpp index 91a32268cf..ed65cd2a82 100644 --- a/tests/auto/qml/v4/tst_v4.cpp +++ b/tests/auto/qml/v4/tst_v4.cpp @@ -64,6 +64,8 @@ private slots: void unnecessaryReeval(); void logicalOr(); void nestedLogicalOr(); + void logicalAnd(); + void nestedLogicalAnd(); void conditionalExpr(); void qtscript(); void qtscript_data(); @@ -208,6 +210,115 @@ void tst_v4::nestedLogicalOr() delete o; } +void tst_v4::logicalAnd() +{ + { + QQmlComponent component(&engine, testFileUrl("logicalAnd.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + ResultObject *ro = qobject_cast(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->result(), 0); + delete o; + } + + { + QQmlComponent component(&engine, testFileUrl("logicalAnd.2.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + ResultObject *ro = qobject_cast(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->result(), 1); + delete o; + } + + { + QQmlComponent component(&engine, testFileUrl("logicalAnd.3.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + ResultObject *ro = qobject_cast(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->result(), 1); + delete o; + } + + { + // QTBUG-24660 + QQmlComponent component(&engine, testFileUrl("logicalAnd.4.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + ResultObject *ro = qobject_cast(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->result(), 1); + delete o; + } + + { + QQmlComponent component(&engine, testFileUrl("logicalAnd.5.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + ResultObject *ro = qobject_cast(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->result(), 1); + delete o; + } + + { + QQmlComponent component(&engine, testFileUrl("logicalAnd.6.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + ResultObject *ro = qobject_cast(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->result(), 1); + delete o; + } + + { + QQmlComponent component(&engine, testFileUrl("logicalAnd.7.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + ResultObject *ro = qobject_cast(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->result(), 1); + delete o; + } +} + +void tst_v4::nestedLogicalAnd() +{ + QQmlComponent component(&engine, testFileUrl("nestedLogicalAnd.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + ResultObject *ro = qobject_cast(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->result(), 1); + delete o; +} + void tst_v4::conditionalExpr() { { -- cgit v1.2.3 From 39327bbe38d90cc4ec10c9dddc5722169f454d4f Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 14 Mar 2012 12:37:09 +0100 Subject: Debugger: Fix autotests on Windows Remove export macro logic for internal classes. Change-Id: I4dfa7f8e7bc9b5086e01e40342bd00812d5966bd Reviewed-by: Aurindam Jana Reviewed-by: Friedemann Kleint --- tests/auto/qml/debugger/shared/qqmldebugclient.h | 4 ++-- tests/auto/qml/debugger/shared/qqmlenginedebug_p.h | 28 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/debugger/shared/qqmldebugclient.h b/tests/auto/qml/debugger/shared/qqmldebugclient.h index d3e5cd59a4..1b05e86a64 100644 --- a/tests/auto/qml/debugger/shared/qqmldebugclient.h +++ b/tests/auto/qml/debugger/shared/qqmldebugclient.h @@ -47,7 +47,7 @@ #include class QQmlDebugConnectionPrivate; -class Q_QML_PRIVATE_EXPORT QQmlDebugConnection : public QIODevice +class QQmlDebugConnection : public QIODevice { Q_OBJECT Q_DISABLE_COPY(QQmlDebugConnection) @@ -81,7 +81,7 @@ private: }; class QQmlDebugClientPrivate; -class Q_QML_PRIVATE_EXPORT QQmlDebugClient : public QObject +class QQmlDebugClient : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QQmlDebugClient) diff --git a/tests/auto/qml/debugger/shared/qqmlenginedebug_p.h b/tests/auto/qml/debugger/shared/qqmlenginedebug_p.h index 70f04d3a19..2ebdebca53 100644 --- a/tests/auto/qml/debugger/shared/qqmlenginedebug_p.h +++ b/tests/auto/qml/debugger/shared/qqmlenginedebug_p.h @@ -73,7 +73,7 @@ class QQmlDebugObjectReference; class QQmlDebugFileReference; class QQmlDebugEngineReference; class QQmlEngineDebugPrivate; -class Q_QML_PRIVATE_EXPORT QQmlEngineDebug : public QObject +class QQmlEngineDebug : public QObject { Q_OBJECT public: @@ -121,7 +121,7 @@ private: Q_DECLARE_PRIVATE(QQmlEngineDebug) }; -class Q_QML_PRIVATE_EXPORT QQmlDebugWatch : public QObject +class QQmlDebugWatch : public QObject { Q_OBJECT public: @@ -152,7 +152,7 @@ private: int m_objectDebugId; }; -class Q_QML_PRIVATE_EXPORT QQmlDebugPropertyWatch : public QQmlDebugWatch +class QQmlDebugPropertyWatch : public QQmlDebugWatch { Q_OBJECT public: @@ -165,7 +165,7 @@ private: QString m_name; }; -class Q_QML_PRIVATE_EXPORT QQmlDebugObjectExpressionWatch : public QQmlDebugWatch +class QQmlDebugObjectExpressionWatch : public QQmlDebugWatch { Q_OBJECT public: @@ -180,7 +180,7 @@ private: }; -class Q_QML_PRIVATE_EXPORT QQmlDebugQuery : public QObject +class QQmlDebugQuery : public QObject { Q_OBJECT public: @@ -202,7 +202,7 @@ private: State m_state; }; -class Q_QML_PRIVATE_EXPORT QQmlDebugFileReference +class QQmlDebugFileReference { public: QQmlDebugFileReference(); @@ -223,7 +223,7 @@ private: int m_columnNumber; }; -class Q_QML_PRIVATE_EXPORT QQmlDebugEngineReference +class QQmlDebugEngineReference { public: QQmlDebugEngineReference(); @@ -240,7 +240,7 @@ private: QString m_name; }; -class Q_QML_PRIVATE_EXPORT QQmlDebugObjectReference +class QQmlDebugObjectReference { public: QQmlDebugObjectReference(); @@ -271,7 +271,7 @@ private: QList m_children; }; -class Q_QML_PRIVATE_EXPORT QQmlDebugContextReference +class QQmlDebugContextReference { public: QQmlDebugContextReference(); @@ -292,7 +292,7 @@ private: QList m_contexts; }; -class Q_QML_PRIVATE_EXPORT QQmlDebugPropertyReference +class QQmlDebugPropertyReference { public: QQmlDebugPropertyReference(); @@ -317,7 +317,7 @@ private: }; -class Q_QML_PRIVATE_EXPORT QQmlDebugEnginesQuery : public QQmlDebugQuery +class QQmlDebugEnginesQuery : public QQmlDebugQuery { Q_OBJECT public: @@ -332,7 +332,7 @@ private: QList m_engines; }; -class Q_QML_PRIVATE_EXPORT QQmlDebugRootContextQuery : public QQmlDebugQuery +class QQmlDebugRootContextQuery : public QQmlDebugQuery { Q_OBJECT public: @@ -347,7 +347,7 @@ private: QQmlDebugContextReference m_context; }; -class Q_QML_PRIVATE_EXPORT QQmlDebugObjectQuery : public QQmlDebugQuery +class QQmlDebugObjectQuery : public QQmlDebugQuery { Q_OBJECT public: @@ -363,7 +363,7 @@ private: }; -class Q_QML_PRIVATE_EXPORT QQmlDebugExpressionQuery : public QQmlDebugQuery +class QQmlDebugExpressionQuery : public QQmlDebugQuery { Q_OBJECT public: -- cgit v1.2.3 From d6c666f73f03d21c658fa7b8435430a2874f9bc6 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 14 Mar 2012 13:21:59 +0100 Subject: Debugger: Fix autotest for shadow builds Change-Id: I1b53afeb2a9f0d6e571c5ed87304e85896523488 Reviewed-by: Aurindam Jana --- tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp | 2 +- tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp index def704060c..e30b847139 100644 --- a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp +++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp @@ -141,7 +141,7 @@ void tst_QQmlInspector::cleanupTestCase() void tst_QQmlInspector::init() { - const QString executable = SRCDIR"/app/app"; + const QString executable = "app/app"; const QString argument = "-qmljsdebugger=port:"STR_PORT",block"; m_process = new QQmlDebugProcess(executable); diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro index c24accac1a..b4ca60b547 100644 --- a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro +++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro @@ -7,7 +7,6 @@ SOURCES += tst_qqmlinspector.cpp INCLUDEPATH += ../shared include(../shared/debugutil.pri) -DEFINES += SRCDIR=\\\"$$PWD\\\" CONFIG += parallel_test declarative_debug QT += qml-private testlib -- cgit v1.2.3 From e1d688a23707b2c093294eea365bdf0d087b3f3c Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 8 Mar 2012 15:15:10 +0100 Subject: Debugger: Print informational messages via qDebug This allows users to use QT_FATAL_WARNINGS. Change-Id: I114825764c841030418c956d23575159157dfd69 Reviewed-by: Roberto Raggi --- tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp | 6 +++--- tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp | 4 ++-- .../debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp index 9377ef6a8f..1682913bc3 100644 --- a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp +++ b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp @@ -72,7 +72,7 @@ private slots: void tst_QQmlDebugClient::initTestCase() { const QString waitingMsg = QString("QML Debugger: Waiting for connection on port %1...").arg(PORT); - QTest::ignoreMessage(QtWarningMsg, waitingMsg.toAscii().constData()); + QTest::ignoreMessage(QtDebugMsg, waitingMsg.toAscii().constData()); new QQmlEngine(this); m_conn = new QQmlDebugConnection(this); @@ -80,7 +80,7 @@ void tst_QQmlDebugClient::initTestCase() QQmlDebugTestClient client("tst_QQmlDebugClient::handshake()", m_conn); QQmlDebugTestService service("tst_QQmlDebugClient::handshake()"); - QTest::ignoreMessage(QtWarningMsg, "QML Debugger: Connection established."); + QTest::ignoreMessage(QtDebugMsg, "QML Debugger: Connection established."); for (int i = 0; i < 50; ++i) { // try for 5 seconds ... m_conn->connectToHost("127.0.0.1", PORT); @@ -172,7 +172,7 @@ void tst_QQmlDebugClient::sequentialConnect() QTest::qWait(100); connection2.connectToHost("127.0.0.1", PORT); - QTest::ignoreMessage(QtWarningMsg, "QML Debugger: Connection established."); + QTest::ignoreMessage(QtDebugMsg, "QML Debugger: Connection established."); QVERIFY(connection2.waitForConnected()); QVERIFY(connection2.isConnected()); QTRY_VERIFY(client2.state() == QQmlDebugClient::Enabled); diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp index a7fc284443..6e14c03a4c 100644 --- a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp +++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp @@ -77,13 +77,13 @@ private slots: void tst_QQmlDebugService::initTestCase() { const QString waitingMsg = QString("QML Debugger: Waiting for connection on port %1...").arg(PORT); - QTest::ignoreMessage(QtWarningMsg, waitingMsg.toAscii().constData()); + QTest::ignoreMessage(QtDebugMsg, waitingMsg.toAscii().constData()); new QQmlEngine(this); m_conn = new QQmlDebugConnection(this); - QTest::ignoreMessage(QtWarningMsg, "QML Debugger: Connection established."); + QTest::ignoreMessage(QtDebugMsg, "QML Debugger: Connection established."); for (int i = 0; i < 50; ++i) { // try for 5 seconds ... m_conn->connectToHost("127.0.0.1", PORT); diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index a35aafff4d..9756313905 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -301,7 +301,7 @@ void tst_QQmlEngineDebugService::initTestCase() qRegisterMetaType(); qmlRegisterType("Test", 1, 0, "NonScriptPropertyElement"); - QTest::ignoreMessage(QtWarningMsg, "QML Debugger: Waiting for connection on port 3768..."); + QTest::ignoreMessage(QtDebugMsg, "QML Debugger: Waiting for connection on port 3768..."); m_engine = new QQmlEngine(this); QList qml; @@ -386,7 +386,7 @@ void tst_QQmlEngineDebugService::initTestCase() m_conn = new QQmlDebugConnection(this); m_conn->connectToHost("127.0.0.1", 3768); - QTest::ignoreMessage(QtWarningMsg, "QML Debugger: Connection established."); + QTest::ignoreMessage(QtDebugMsg, "QML Debugger: Connection established."); bool ok = m_conn->waitForConnected(); QVERIFY(ok); QTRY_VERIFY(QQmlDebugService::hasDebuggingClient()); -- cgit v1.2.3 From f91dba12746bb1675bfe3a483288e712a867dd7c Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 14 Mar 2012 12:51:22 +0100 Subject: Use the same ReferenceError message wording as V8 Instead of "Can't find variable: foo", use "foo is not defined". This is in preparation of letting V8 throw the exception when a property lookup fails on the QML scope object (needed for QTBUG-24448). Change-Id: I3c747482a8ef138dad9a85530a4f6b5c4c818a03 Reviewed-by: Aaron Kennedy --- tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp | 2 +- .../auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 38 +++++++++++----------- .../qquickworkerscript/tst_qquickworkerscript.cpp | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp index 6125362365..6525bde9b8 100644 --- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp +++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp @@ -617,7 +617,7 @@ void tst_qqmlcontext::refreshExpressionsRootContext() QQmlContext context(engine.rootContext()); QQmlContext context2(engine.rootContext()); - QString warning = component2.url().toString() + QLatin1String(":4: ReferenceError: Can't find variable: unresolvedName"); + QString warning = component2.url().toString() + QLatin1String(":4: ReferenceError: unresolvedName is not defined"); QObject *o1 = component.create(&context); diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 0631df1759..3fe0a2bd1a 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -1416,10 +1416,10 @@ void tst_qqmlecmascript::scriptErrors() QString url = component.url().toString(); QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\""; - QString warning2 = url + ":5: ReferenceError: Can't find variable: a"; + QString warning2 = url + ":5: ReferenceError: a is not defined"; QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\""; - QString warning4 = url + ":13: ReferenceError: Can't find variable: a"; - QString warning5 = url + ":11: ReferenceError: Can't find variable: a"; + QString warning4 = url + ":13: ReferenceError: a is not defined"; + QString warning5 = url + ":11: ReferenceError: a is not defined"; QString warning6 = url + ":10: Unable to assign [undefined] to int"; QString warning7 = url + ":15: Error: Cannot assign to read-only property \"trueProperty\""; QString warning8 = url + ":16: Error: Cannot assign to non-existent property \"fakeProperty\""; @@ -3216,7 +3216,7 @@ void tst_qqmlecmascript::importScripts_data() QTest::newRow("javascript imports in an import should be private to the import scope") << testFileUrl("jsimportfail/failTwo.qml") << QString() - << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failTwo.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: ImportOneJs"))) + << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failTwo.qml").toLocalFile() + QLatin1String(":6: ReferenceError: ImportOneJs is not defined"))) << (QStringList() << QLatin1String("importScriptFunctionValue")) << (QVariantList() << QVariant(QString())); @@ -3230,14 +3230,14 @@ void tst_qqmlecmascript::importScripts_data() QTest::newRow("typenames in an import should be private to the import scope") << testFileUrl("jsimportfail/failFour.qml") << QString() - << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failFour.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: JsQtTest"))) + << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failFour.qml").toLocalFile() + QLatin1String(":6: ReferenceError: JsQtTest is not defined"))) << (QStringList() << QLatin1String("importedModuleEnumValue")) << (QVariantList() << QVariant(0)); QTest::newRow("import with imports has it's own activation scope") << testFileUrl("jsimportfail/failFive.qml") << QString() - << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importWithImports.js").toLocalFile() + QLatin1String(":8: ReferenceError: Can't find variable: Component"))) + << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importWithImports.js").toLocalFile() + QLatin1String(":8: ReferenceError: Component is not defined"))) << (QStringList() << QLatin1String("componentError")) << (QVariantList() << QVariant(0)); @@ -3251,7 +3251,7 @@ void tst_qqmlecmascript::importScripts_data() QTest::newRow("pragma library imports shouldn't inherit parent imports or scope") << testFileUrl("jsimportfail/testImportPragmaLibrary.qml") << QString() - << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importPragmaLibrary.js").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: Component"))) + << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importPragmaLibrary.js").toLocalFile() + QLatin1String(":6: ReferenceError: Component is not defined"))) << (QStringList() << QLatin1String("testValue")) << (QVariantList() << QVariant(0)); @@ -5378,7 +5378,7 @@ void tst_qqmlecmascript::typeOf() // These warnings should not happen once QTBUG-21864 is fixed QString warning1 = component.url().toString() + QLatin1String(":16: Error: Cannot assign [undefined] to QString"); - QString warning2 = component.url().resolved(QUrl("typeOf.js")).toString() + QLatin1String(":1: ReferenceError: Can't find variable: a"); + QString warning2 = component.url().resolved(QUrl("typeOf.js")).toString() + QLatin1String(":1: ReferenceError: a is not defined"); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -5550,9 +5550,9 @@ void tst_qqmlecmascript::revisionErrors() QQmlComponent component(&engine, testFileUrl("metaobjectRevisionErrors.qml")); QString url = component.url().toString(); - QString warning1 = url + ":8: ReferenceError: Can't find variable: prop2"; - QString warning2 = url + ":11: ReferenceError: Can't find variable: prop2"; - QString warning3 = url + ":13: ReferenceError: Can't find variable: method2"; + QString warning1 = url + ":8: ReferenceError: prop2 is not defined"; + QString warning2 = url + ":11: ReferenceError: prop2 is not defined"; + QString warning3 = url + ":13: ReferenceError: method2 is not defined"; QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData()); QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData()); @@ -5568,11 +5568,11 @@ void tst_qqmlecmascript::revisionErrors() // MyRevisionedSubclass 1.0 uses MyRevisionedClass revision 0 // method2, prop2 from MyRevisionedClass not available // method4, prop4 from MyRevisionedSubclass not available - QString warning1 = url + ":8: ReferenceError: Can't find variable: prop2"; - QString warning2 = url + ":14: ReferenceError: Can't find variable: prop2"; - QString warning3 = url + ":10: ReferenceError: Can't find variable: prop4"; - QString warning4 = url + ":16: ReferenceError: Can't find variable: prop4"; - QString warning5 = url + ":20: ReferenceError: Can't find variable: method2"; + QString warning1 = url + ":8: ReferenceError: prop2 is not defined"; + QString warning2 = url + ":14: ReferenceError: prop2 is not defined"; + QString warning3 = url + ":10: ReferenceError: prop4 is not defined"; + QString warning4 = url + ":16: ReferenceError: prop4 is not defined"; + QString warning5 = url + ":20: ReferenceError: method2 is not defined"; QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData()); QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData()); @@ -5589,9 +5589,9 @@ void tst_qqmlecmascript::revisionErrors() // MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1 // All properties/methods available, except MyRevisionedBaseClassUnregistered rev 1 - QString warning1 = url + ":30: ReferenceError: Can't find variable: methodD"; - QString warning2 = url + ":10: ReferenceError: Can't find variable: propD"; - QString warning3 = url + ":20: ReferenceError: Can't find variable: propD"; + QString warning1 = url + ":30: ReferenceError: methodD is not defined"; + QString warning2 = url + ":10: ReferenceError: propD is not defined"; + QString warning3 = url + ":20: ReferenceError: propD is not defined"; QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData()); QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData()); QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData()); diff --git a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp index 6569b877fe..2eadc461cf 100644 --- a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp +++ b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp @@ -275,7 +275,7 @@ void tst_QQuickWorkerScript::scriptError_onCall() QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value))); QTRY_COMPARE(qquickworkerscript_lastWarning, - testFileUrl("script_error_onCall.js").toString() + QLatin1String(":4: ReferenceError: Can't find variable: getData")); + testFileUrl("script_error_onCall.js").toString() + QLatin1String(":4: ReferenceError: getData is not defined")); qInstallMsgHandler(previousMsgHandler); qApp->processEvents(); -- cgit v1.2.3 From dfe32bec2d2397b8f52f5ec54bf3c69f086eadea Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 14 Mar 2012 16:52:35 +0200 Subject: Windows: Mark several declarative test cases insignificant These tests are marked insignificant for now to make CI runs pass. Insignifications need to be removed once the related issues are fixed. Change-Id: I3a1d36e5b17cf2f1b2f00b20b615359d96975f2b Reviewed-by: Friedemann Kleint --- tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro b/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro index 2726e20577..68c0d79f92 100644 --- a/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro +++ b/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro @@ -10,3 +10,5 @@ TESTDATA = data/* CONFIG += parallel_test QT += core-private gui-private qml-private testlib + +win32:CONFIG += insignificant_test # QTBUG-24777 -- cgit v1.2.3 From 8f077f28c51c24e71d95c4e99d322734578d9c9c Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 14 Mar 2012 16:56:22 +0200 Subject: Remove warning about missing file from parserstress test There is no dummy.qml, so trying to find it will cause a warning and return an empty string. Since the url is optional anyway and apparently not relevant to this test, just use empty QUrl directly. Change-Id: I11ba742dedccd6bdea226f680aa57c957afc7dc7 Reviewed-by: Friedemann Kleint --- tests/auto/qml/parserstress/tst_parserstress.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/parserstress/tst_parserstress.cpp b/tests/auto/qml/parserstress/tst_parserstress.cpp index a179a24f5f..eb477af521 100644 --- a/tests/auto/qml/parserstress/tst_parserstress.cpp +++ b/tests/auto/qml/parserstress/tst_parserstress.cpp @@ -128,8 +128,7 @@ void tst_parserstress::ecmascript() QQmlComponent component(&engine); - QString dummyFile = QFINDTESTDATA("dummy.qml"); - component.setData(qmlData, QUrl::fromLocalFile(dummyFile)); + component.setData(qmlData, QUrl()); QFileInfo info(file); -- cgit v1.2.3 From a27fd584df0ec3d1d072501d8fefe576a97a2e53 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 14 Mar 2012 13:39:31 +0100 Subject: Let V8 throw the exception when QML property lookup fails Only V8 knows whether a failed property lookup should actually cause a ReferenceError to be thrown. When evaluating a "typeof" expression, for example, a ReferenceError should not be thrown even if the expression involves global variables that don't exist, according to the ECMA-262 specification. QML should try to match the standard JavaScript behavior. This is achieved by simply returning an empty value handle (to signify the absence of the property), and leaving it to V8 to throw an exception as appropriate. Task-number: QTBUG-21864 Task-number: QTBUG-24448 Change-Id: I9945adcab98fc3b801371163367473d6af0ab31a Reviewed-by: Aaron Kennedy --- tests/auto/qml/qqmlecmascript/data/qtbug_24448.js | 6 ++++++ tests/auto/qml/qqmlecmascript/data/qtbug_24448.qml | 7 +++++++ tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 17 +++++++++-------- 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug_24448.js create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug_24448.qml (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_24448.js b/tests/auto/qml/qqmlecmascript/data/qtbug_24448.js new file mode 100644 index 0000000000..eefe00337c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_24448.js @@ -0,0 +1,6 @@ +var test = false; +try { + eval(foo); +} catch (e) { + test = (typeof foo) === "undefined"; +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_24448.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_24448.qml new file mode 100644 index 0000000000..d8d305d104 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_24448.qml @@ -0,0 +1,7 @@ +import "qtbug_24448.js" as Test +import QtQuick 2.0 + +QtObject { + property bool test: Test.test +} + diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 3fe0a2bd1a..8fea635b68 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -207,6 +207,7 @@ private slots: void deleteLater(); void in(); void typeOf(); + void qtbug_24448(); void sharedAttachedObject(); void objectName(); void writeRemovesBinding(); @@ -5376,17 +5377,9 @@ void tst_qqmlecmascript::typeOf() { QQmlComponent component(&engine, testFileUrl("typeOf.qml")); - // These warnings should not happen once QTBUG-21864 is fixed - QString warning1 = component.url().toString() + QLatin1String(":16: Error: Cannot assign [undefined] to QString"); - QString warning2 = component.url().resolved(QUrl("typeOf.js")).toString() + QLatin1String(":1: ReferenceError: a is not defined"); - - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); - QObject *o = component.create(); QVERIFY(o != 0); - QEXPECT_FAIL("", "QTBUG-21864", Abort); QCOMPARE(o->property("test1").toString(), QLatin1String("undefined")); QCOMPARE(o->property("test2").toString(), QLatin1String("object")); QCOMPARE(o->property("test3").toString(), QLatin1String("number")); @@ -5400,6 +5393,14 @@ void tst_qqmlecmascript::typeOf() delete o; } +void tst_qqmlecmascript::qtbug_24448() +{ + QQmlComponent component(&engine, testFileUrl("qtbug_24448.qml")); + QScopedPointer o(component.create()); + QVERIFY(o != 0); + QVERIFY(o->property("test").toBool()); +} + void tst_qqmlecmascript::sharedAttachedObject() { QQmlComponent component(&engine, testFileUrl("sharedAttachedObject.qml")); -- cgit v1.2.3 From b06108350b1390b51886474628e03e2e84640548 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Fri, 27 Jan 2012 11:33:37 +1000 Subject: Ensure that dynamic property storing QObject ptr notifies on delete Previously, when a QObject ptr was stored in a dynamic variant property, the value of the property could change (to a zero ptr) if the QObject was deleted without a notify signal being emitted by the QDeclarativeVMEMetaObject which stores the property. This commit ensures that such a notify signal is emitted correctly. Task-number: QTBUG-23451 Change-Id: I5689abd984b177737f8d5f18950838b73ebde328 Reviewed-by: Martin Jones --- .../qml/qqmlecmascript/data/dynamicDeletion.3.qml | 30 ++++++++++++++++++++++ .../auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 22 ++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 tests/auto/qml/qqmlecmascript/data/dynamicDeletion.3.qml (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qqmlecmascript/data/dynamicDeletion.3.qml b/tests/auto/qml/qqmlecmascript/data/dynamicDeletion.3.qml new file mode 100644 index 0000000000..3739150bc4 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/dynamicDeletion.3.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: root + property bool test: false + property QtObject objectProperty + + onObjectPropertyChanged: { + root.test = true; + } + + property Component c: Component { + id: dynamicComponent + QtObject { + id: dynamicObject + } + } + + function create() { + root.objectProperty = root.c.createObject(root); + } + + function destroy() { + root.test = false; // reset test + root.objectProperty.destroy(100); + // in cpp, wait objectProperty deletion, inspect "test" and "objectProperty" + // test should be true and value of objectProperty should be zero. + } +} diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 8fea635b68..e3ad1e71cb 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -1288,6 +1288,28 @@ void tst_qqmlecmascript::dynamicDestruction() delete o; } + + { + // QTBUG-23451 + QQmlGuard createdQmlObject = 0; + QQmlComponent component(&engine, testFileUrl("dynamicDeletion.3.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QVERIFY(qvariant_cast(o->property("objectProperty")) == 0); + QMetaObject::invokeMethod(o, "create"); + createdQmlObject = qvariant_cast(o->property("objectProperty")); + QVERIFY(createdQmlObject); + QMetaObject::invokeMethod(o, "destroy"); + QVERIFY(qvariant_cast(o->property("test")) == false); + for (int ii = 0; createdQmlObject && ii < 50; ++ii) { // After 5 seconds we should give up + QTest::qWait(100); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + } + QVERIFY(qvariant_cast(o->property("objectProperty")) == 0); + QVERIFY(qvariant_cast(o->property("test")) == true); + delete o; + } } /* -- cgit v1.2.3 From 5ae8caba10a79c2298939aff777a0201959a94af Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 9 Mar 2012 09:16:50 +0100 Subject: Remove binding dependency on QQmlExpression This is the first step to creating much lighter weight bindings that are tuned for the specific scenario in which they're used. Change-Id: Ib985dcff25679b711b5c634bbc891aa7902bf405 Reviewed-by: Michael Brasser --- .../auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 6 ++-- tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp | 42 +++++++++++----------- 2 files changed, 24 insertions(+), 24 deletions(-) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index e3ad1e71cb..cca008eb0c 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -5045,7 +5045,7 @@ void tst_qqmlecmascript::functionAssignment_fromBinding() QQmlComponent component(&engine, testFileUrl("functionAssignment.1.qml")); QString url = component.url().toString(); - QString warning = url + ":4: Unable to assign a function to a property."; + QString warning = url + ":4:25: Unable to assign a function to a property."; QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); MyQmlObject *o = qobject_cast(component.create()); @@ -5103,11 +5103,11 @@ void tst_qqmlecmascript::functionAssignmentfromJS_invalid() QVERIFY(!o->property("a").isValid()); QString url = component.url().toString(); - QString warning = url + ":67: Unable to assign QString to int"; + QString warning = url + ":67:17: Unable to assign QString to int"; QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); o->setProperty("assignWrongType", true); - warning = url + ":71: Unable to assign QString to int"; + warning = url + ":71:29: Unable to assign QString to int"; QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); o->setProperty("assignWrongTypeToValueType", true); diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index ae300900c9..5ef8937dc1 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -143,7 +143,7 @@ void tst_qqmlproperty::qmlmetaproperty() { QQmlProperty prop; - QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + QWeakPointer binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); QVERIFY(binding != 0); QWeakPointer expression(new QQmlExpression()); QVERIFY(expression != 0); @@ -246,7 +246,7 @@ void tst_qqmlproperty::qmlmetaproperty_object() { QQmlProperty prop(&object); - QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + QWeakPointer binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); QVERIFY(binding != 0); QWeakPointer expression(new QQmlExpression()); QVERIFY(expression != 0); @@ -292,8 +292,8 @@ void tst_qqmlproperty::qmlmetaproperty_object() { QQmlProperty prop(&dobject); - QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); - binding.data()->setTarget(prop); + QWeakPointer binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); + static_cast(binding.data())->setTarget(prop); QVERIFY(binding != 0); QWeakPointer expression(new QQmlExpression()); QVERIFY(expression != 0); @@ -347,7 +347,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&object, QString("defaultProperty")); - QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + QWeakPointer binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); QVERIFY(binding != 0); QWeakPointer expression(new QQmlExpression()); QVERIFY(expression != 0); @@ -393,8 +393,8 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&dobject, QString("defaultProperty")); - QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); - binding.data()->setTarget(prop); + QWeakPointer binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); + static_cast(binding.data())->setTarget(prop); QVERIFY(binding != 0); QWeakPointer expression(new QQmlExpression()); QVERIFY(expression != 0); @@ -442,8 +442,8 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&dobject, QString("onClicked")); - QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); - binding.data()->setTarget(prop); + QWeakPointer binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); + static_cast(binding.data())->setTarget(prop); QVERIFY(binding != 0); QWeakPointer expression(new QQmlExpression()); QVERIFY(expression != 0); @@ -490,8 +490,8 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged")); - QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); - binding.data()->setTarget(prop); + QWeakPointer binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); + static_cast(binding.data())->setTarget(prop); QVERIFY(binding != 0); QWeakPointer expression(new QQmlExpression()); QVERIFY(expression != 0); @@ -544,7 +544,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() { QQmlProperty prop(&object, engine.rootContext()); - QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + QWeakPointer binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); QVERIFY(binding != 0); QWeakPointer expression(new QQmlExpression()); QVERIFY(expression != 0); @@ -590,8 +590,8 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() { QQmlProperty prop(&dobject, engine.rootContext()); - QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); - binding.data()->setTarget(prop); + QWeakPointer binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); + static_cast(binding.data())->setTarget(prop); QVERIFY(binding != 0); QWeakPointer expression(new QQmlExpression()); QVERIFY(expression != 0); @@ -645,7 +645,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&object, QString("defaultProperty"), engine.rootContext()); - QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + QWeakPointer binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); QVERIFY(binding != 0); QWeakPointer expression(new QQmlExpression()); QVERIFY(expression != 0); @@ -691,8 +691,8 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&dobject, QString("defaultProperty"), engine.rootContext()); - QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); - binding.data()->setTarget(prop); + QWeakPointer binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); + static_cast(binding.data())->setTarget(prop); QVERIFY(binding != 0); QWeakPointer expression(new QQmlExpression()); QVERIFY(expression != 0); @@ -740,8 +740,8 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&dobject, QString("onClicked"), engine.rootContext()); - QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); - binding.data()->setTarget(prop); + QWeakPointer binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); + static_cast(binding.data())->setTarget(prop); QVERIFY(binding != 0); QWeakPointer expression(new QQmlExpression()); QVERIFY(expression != 0); @@ -788,8 +788,8 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged"), engine.rootContext()); - QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); - binding.data()->setTarget(prop); + QWeakPointer binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); + static_cast(binding.data())->setTarget(prop); QVERIFY(binding != 0); QWeakPointer expression(new QQmlExpression()); QVERIFY(expression != 0); -- cgit v1.2.3 From 147247a31a9d6c1edadb0c7c78cf10b894dfab25 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Thu, 15 Mar 2012 10:20:26 +1000 Subject: Don't allow tst_QJSEngine or tst_QJSValue instance to be collected Both of those unit tests currently change the ownership of the test instance object, which could result in it being collected by the JS GC and deleted if events were processed. Change-Id: I5a9821fb56e19af1d52fea46e54755875dfbb29a Reviewed-by: Michael Brasser --- tests/auto/qml/qjsengine/tst_qjsengine.cpp | 24 +++++++++++++-------- tests/auto/qml/qjsvalue/tst_qjsvalue.cpp | 34 ++++++++++++++++++------------ 2 files changed, 36 insertions(+), 22 deletions(-) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 66fef8e2dd..6f9cc93757 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -899,6 +899,7 @@ void tst_QJSEngine::jsParseDate() void tst_QJSEngine::newQObject() { QJSEngine eng; + QObject temp; { QJSValue qobject = eng.newQObject(0); @@ -907,11 +908,11 @@ void tst_QJSEngine::newQObject() QCOMPARE(qobject.toQObject(), (QObject *)0); } { - QJSValue qobject = eng.newQObject(this); + QJSValue qobject = eng.newQObject(&temp); QVERIFY(!qobject.isUndefined()); QCOMPARE(qobject.isQObject(), true); QCOMPARE(qobject.isObject(), true); - QCOMPARE(qobject.toQObject(), (QObject *)this); + QCOMPARE(qobject.toQObject(), (QObject *)&temp); QVERIFY(!qobject.isCallable()); // prototype should be QObject.prototype QCOMPARE(qobject.prototype().isObject(), true); @@ -1068,6 +1069,7 @@ void tst_QJSEngine::newQObject_sameQObject() #if 0 // FIXME: No prototype API in QScriptEngine void tst_QJSEngine::newQObject_defaultPrototype() { + QObject temp; QScriptEngine eng; // newQObject() should set the default prototype, if one has been registered { @@ -1076,14 +1078,14 @@ void tst_QJSEngine::newQObject_defaultPrototype() QScriptValue qobjectProto = eng.newObject(); eng.setDefaultPrototype(qMetaTypeId(), qobjectProto); { - QScriptValue ret = eng.newQObject(this); + QScriptValue ret = eng.newQObject(&temp); QVERIFY(ret.prototype().equals(qobjectProto)); } QScriptValue tstProto = eng.newObject(); int typeId = qRegisterMetaType("tst_QJSEngine*"); eng.setDefaultPrototype(typeId, tstProto); { - QScriptValue ret = eng.newQObject(this); + QScriptValue ret = eng.newQObject(temp); QVERIFY(ret.prototype().equals(tstProto)); } @@ -1261,7 +1263,8 @@ void tst_QJSEngine::newQMetaObject() QVERIFY(instanceofJS(inst, qclass3).strictlyEquals(false)); } { - QScriptValue inst = qclass4.callAsConstructor(QScriptValueList() << eng.newQObject(this)); + QObject temp; + QScriptValue inst = qclass4.callAsConstructor(QScriptValueList() << eng.newQObject(&temp)); QVERIFY(inst.isQObject()); QVERIFY(inst.toQObject() != 0); QCOMPARE(inst.toQObject()->parent(), (QObject*)this); @@ -2887,6 +2890,7 @@ void tst_QJSEngine::castWithPrototypeChain() QScriptEngine eng; Bar bar; Baz baz; + QObject temp; QScriptValue barProto = eng.toScriptValue(&bar); QScriptValue bazProto = eng.toScriptValue(&baz); eng.setDefaultPrototype(qMetaTypeId(), barProto); @@ -2954,7 +2958,7 @@ void tst_QJSEngine::castWithPrototypeChain() QVERIFY(pbar == 0); } - bazProto.setPrototype(eng.newQObject(this)); + bazProto.setPrototype(eng.newQObject(&temp)); { Baz *pbaz = qscriptvalue_cast(baz2Value); QVERIFY(pbaz != 0); @@ -3756,8 +3760,9 @@ private: QScriptEngine* m_engine; protected: void run() { + QObject temp; m_engine = new QScriptEngine(); - m_engine->setGlobalObject(m_engine->newQObject(this)); + m_engine->setGlobalObject(m_engine->newQObject(&temp)); m_engine->evaluate("while (1) { sleep(); }"); delete m_engine; } @@ -4941,6 +4946,7 @@ void tst_QJSEngine::reentrancy_Array() void tst_QJSEngine::reentrancy_objectCreation() { + QObject temp; QJSEngine eng1; QJSEngine eng2; { @@ -4957,8 +4963,8 @@ void tst_QJSEngine::reentrancy_objectCreation() QCOMPARE(qjsvalue_cast(r2), qjsvalue_cast(r1)); } { - QJSValue o1 = eng1.newQObject(this); - QJSValue o2 = eng2.newQObject(this); + QJSValue o1 = eng1.newQObject(&temp); + QJSValue o2 = eng2.newQObject(&temp); QCOMPARE(o1.toQObject(), o2.toQObject()); QCOMPARE(o2.toQObject(), o1.toQObject()); } diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index cec10ccf38..ad655217ad 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -986,6 +986,7 @@ Q_DECLARE_METATYPE(QVariant) void tst_QJSValue::toVariant() { QJSEngine eng; + QObject temp; QJSValue undefined = eng.toScriptValue(QVariant()); QCOMPARE(undefined.toVariant(), QVariant()); @@ -1020,11 +1021,11 @@ void tst_QJSValue::toVariant() QJSValue object = eng.newObject(); QCOMPARE(object.toVariant(), QVariant(QVariantMap())); - QJSValue qobject = eng.newQObject(this); + QJSValue qobject = eng.newQObject(&temp); { QVariant var = qobject.toVariant(); QCOMPARE(var.userType(), int(QMetaType::QObjectStar)); - QCOMPARE(qVariantValue(var), (QObject *)this); + QCOMPARE(qVariantValue(var), (QObject *)&temp); } { @@ -1130,10 +1131,11 @@ Q_DECLARE_METATYPE(QPushButton*); void tst_QJSValue::toQObject() { QJSEngine eng; + QObject temp; - QJSValue qobject = eng.newQObject(this); - QCOMPARE(qobject.toQObject(), (QObject *)this); - QCOMPARE(qjsvalue_cast(qobject), (QObject *)this); + QJSValue qobject = eng.newQObject(&temp); + QCOMPARE(qobject.toQObject(), (QObject *)&temp); + QCOMPARE(qjsvalue_cast(qobject), (QObject *)&temp); QCOMPARE(qjsvalue_cast(qobject), (QWidget *)0); QWidget widget; @@ -2168,6 +2170,7 @@ void tst_QJSValue::getSetData_objects_data() { #if 0 // FIXME: no setData/data API newEngine(); + QObject *temp = new QObject; QTest::addColumn("object"); @@ -2175,7 +2178,7 @@ void tst_QJSValue::getSetData_objects_data() QTest::newRow("object from engine") << engine->newObject(); QTest::newRow("Array") << engine->newArray(); QTest::newRow("Date") << engine->evaluate("new Date(12324)"); - QTest::newRow("QObject") << engine->newQObject(this); + QTest::newRow("QObject") << engine->newQObject(temp); QTest::newRow("RegExp") << engine->newRegExp(QRegExp()); #endif } @@ -2265,6 +2268,7 @@ public: void tst_QJSValue::getSetScriptClass_emptyClass_data() { newEngine(); + QObject *temp = new QObject; QTest::addColumn("value"); QTest::newRow("invalid") << QJSValue(); @@ -2281,7 +2285,7 @@ void tst_QJSValue::getSetScriptClass_emptyClass_data() QTest::newRow("undefined") << QJSValue(engine->toScriptValue(QVariant())); QTest::newRow("object") << QJSValue(engine->newObject()); QTest::newRow("date") << QJSValue(engine->evaluate("new Date()")); - QTest::newRow("qobject") << QJSValue(engine->newQObject(this)); + QTest::newRow("qobject") << QJSValue(engine->newQObject(temp)); } void tst_QJSValue::getSetScriptClass_emptyClass() @@ -2341,9 +2345,10 @@ void tst_QJSValue::getSetScriptClass_QVariant() void tst_QJSValue::getSetScriptClass_QObject() { QScriptEngine eng; + QObject temp; TestScriptClass testClass(&eng); { - QJSValue obj = eng.newQObject(this); + QJSValue obj = eng.newQObject(&temp); QVERIFY(obj.isQObject()); obj.setScriptClass(&testClass); QCOMPARE(obj.scriptClass(), (QScriptClass*)&testClass); @@ -2999,6 +3004,7 @@ void tst_QJSValue::lessThan() void tst_QJSValue::equals() { QJSEngine eng; + QObject temp; QVERIFY(QJSValue().equals(QJSValue())); @@ -3088,8 +3094,8 @@ void tst_QJSValue::equals() QCOMPARE(obj1.equals(obj1), true); QCOMPARE(obj2.equals(obj2), true); - QJSValue qobj1 = eng.newQObject(this); - QJSValue qobj2 = eng.newQObject(this); + QJSValue qobj1 = eng.newQObject(&temp); + QJSValue qobj2 = eng.newQObject(&temp); QJSValue qobj3 = eng.newQObject(0); // FIXME: No ScriptOwnership: QJSValue qobj4 = eng.newQObject(new QObject(), QScriptEngine::ScriptOwnership); @@ -3137,6 +3143,7 @@ void tst_QJSValue::equals() void tst_QJSValue::strictlyEquals() { QJSEngine eng; + QObject temp; QVERIFY(QJSValue().strictlyEquals(QJSValue())); @@ -3242,8 +3249,8 @@ void tst_QJSValue::strictlyEquals() QCOMPARE(obj2.strictlyEquals(obj2), true); QVERIFY(!obj1.strictlyEquals(QJSValue())); - QJSValue qobj1 = eng.newQObject(this); - QJSValue qobj2 = eng.newQObject(this); + QJSValue qobj1 = eng.newQObject(&temp); + QJSValue qobj2 = eng.newQObject(&temp); QVERIFY(qobj1.strictlyEquals(qobj2)); { @@ -3482,13 +3489,14 @@ void tst_QJSValue::prettyPrinter() void tst_QJSValue::engineDeleted() { QJSEngine *eng = new QJSEngine; + QObject temp; QJSValue v1 = eng->toScriptValue(123); QVERIFY(v1.isNumber()); QJSValue v2 = eng->toScriptValue(QString("ciao")); QVERIFY(v2.isString()); QJSValue v3 = eng->newObject(); QVERIFY(v3.isObject()); - QJSValue v4 = eng->newQObject(this); + QJSValue v4 = eng->newQObject(&temp); QVERIFY(v4.isQObject()); QJSValue v5 = "Hello"; QVERIFY(v2.isString()); -- cgit v1.2.3 From 25793276e52240e4dfad297dc5b9eb282ed3f5e6 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Tue, 13 Mar 2012 13:30:39 +1000 Subject: Fix crash caused by dereferencing collected v8 data If a var property of a QObject is read after the v8 data associated with the qobject has been deleted but prior to the DeferredDelete event being processed, the varProperties array will be null and a crash will occur. This patch ensures that we check for this condition in both the access and set codepaths for var properties, and also ensures that an object which has previously been queued for deletion cannot be referenced in JS. Finally, it adds a unit test to ensure that we don't regress. Task-number: QTBUG-24748 Change-Id: Idde384ca01e18f4dcf9e376e9379f2c5eb410e14 Reviewed-by: Michael Brasser --- .../qqmlecmascript/data/ComponentWithVarProp.qml | 5 ++++ .../qqmlecmascript/data/propertyVarOwnership.5.qml | 28 ++++++++++++++++++++++ tests/auto/qml/qqmlecmascript/testtypes.h | 8 ++++++- .../auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 9 +++++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qml/qqmlecmascript/data/ComponentWithVarProp.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qqmlecmascript/data/ComponentWithVarProp.qml b/tests/auto/qml/qqmlecmascript/data/ComponentWithVarProp.qml new file mode 100644 index 0000000000..3105b8c79f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/ComponentWithVarProp.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property var varprop: true +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml new file mode 100644 index 0000000000..ad5807b1cf --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 +import Qt.test 1.0 as ModuleApi + +Item { + id: testOwnership + property bool test: false + + function runTest() { + var o; + var c = Qt.createComponent("ComponentWithVarProp.qml"); + if (c.status == Component.Ready) { + o = c.createObject(); + } else { + return; // failed to create component. + } + o.varprop = true; // causes initialization of varProperties. + ModuleApi.trackObject(o); // stores QObject ptr + if (ModuleApi.trackedObject() == null) return; // is still valid, should have a valid v8object. + o = new Date(); // causes object to be gc-able. + gc(); // collect object's v8object + varProperties, queues deleteLater. + if (ModuleApi.trackedObject() != null) return; // v8object was previously collected. + ModuleApi.setTrackedObjectProperty("varprop"); // deferences varProperties of object. + test = !(ModuleApi.trackedObjectProperty("varprop")); // deferences varProperties of object. + // if we didn't crash, success. + } +} + + diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index 65b84d66cb..54fab26405 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -982,7 +982,7 @@ class testQObjectApi : public QObject public: testQObjectApi(QObject* parent = 0) - : QObject(parent), m_testProperty(0), m_testWritableProperty(0), m_testWritableFinalProperty(0), m_methodCallCount(0) + : QObject(parent), m_testProperty(0), m_testWritableProperty(0), m_testWritableFinalProperty(0), m_methodCallCount(0), m_trackedObject(0) { } @@ -992,6 +992,11 @@ public: Q_INVOKABLE int qobjectEnumTestMethod(MyEnum val) { return (static_cast(val) + 5); } Q_INVOKABLE int qobjectTestMethod(int increment = 1) { m_methodCallCount += increment; return m_methodCallCount; } + Q_INVOKABLE void trackObject(QObject *obj) { m_trackedObject = obj; } + Q_INVOKABLE QObject *trackedObject() const { return m_trackedObject; } + Q_INVOKABLE void setTrackedObjectProperty(const QString &propName) const { m_trackedObject->setProperty(qPrintable(propName), QVariant(5)); } + Q_INVOKABLE QVariant trackedObjectProperty(const QString &propName) const { return m_trackedObject->property(qPrintable(propName)); } + int qobjectTestProperty() const { return m_testProperty; } void setQObjectTestProperty(int tp) { m_testProperty = tp; emit qobjectTestPropertyChanged(tp); } @@ -1011,6 +1016,7 @@ private: int m_testWritableProperty; int m_testWritableFinalProperty; int m_methodCallCount; + QObject *m_trackedObject; }; class CircularReferenceObject : public QObject, diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index cca008eb0c..3bbbc2c79c 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -3906,6 +3906,15 @@ void tst_qqmlecmascript::propertyVarOwnership() delete object; } + // Garbage collection cannot result in attempted dereference of empty handle + { + QQmlComponent component(&engine, testFileUrl("propertyVarOwnership.5.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QMetaObject::invokeMethod(object, "runTest"); + QCOMPARE(object->property("test").toBool(), true); + delete object; + } } void tst_qqmlecmascript::propertyVarImplicitOwnership() -- cgit v1.2.3 From 31467e8649979d06ea2f676768016e6a147eadb9 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 6 Mar 2012 18:03:33 +1000 Subject: Allow threaded compilation in an async Loader Enables threaded compilation for a Loader "source". Change-Id: I2d60a3ace07aab58f3b8f069e45a2864178c959f Reviewed-by: Chris Adams --- .../qml/qqmlcomponent/data/TestComponent.2.qml | 591 ++++++++++++++++++++ .../auto/qml/qqmlcomponent/data/TestComponent.qml | 534 +++++++++++++++++++ tests/auto/qml/qqmlcomponent/qqmlcomponent.pro | 8 +- tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp | 101 ++++ tests/auto/qml/qqmlqt/data/TestComponent.2.qml | 592 +++++++++++++++++++++ tests/auto/qml/qqmlqt/data/TestComponent.3.qml | 89 ++++ tests/auto/qml/qqmlqt/data/TestComponent.qml | 534 +++++++++++++++++++ tests/auto/qml/qqmlqt/data/createComponent.2.qml | 27 + tests/auto/qml/qqmlqt/data/createComponent.qml | 13 + tests/auto/qml/qqmlqt/tst_qqmlqt.cpp | 13 + 10 files changed, 2500 insertions(+), 2 deletions(-) create mode 100644 tests/auto/qml/qqmlcomponent/data/TestComponent.2.qml create mode 100644 tests/auto/qml/qqmlcomponent/data/TestComponent.qml create mode 100644 tests/auto/qml/qqmlqt/data/TestComponent.2.qml create mode 100644 tests/auto/qml/qqmlqt/data/TestComponent.3.qml create mode 100644 tests/auto/qml/qqmlqt/data/TestComponent.qml create mode 100644 tests/auto/qml/qqmlqt/data/createComponent.2.qml (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qqmlcomponent/data/TestComponent.2.qml b/tests/auto/qml/qqmlcomponent/data/TestComponent.2.qml new file mode 100644 index 0000000000..fca43fe2dc --- /dev/null +++ b/tests/auto/qml/qqmlcomponent/data/TestComponent.2.qml @@ -0,0 +1,591 @@ +import QtQuick 2.0 + +Item { + id: root + objectName: "root" + property int zero: 0 + + Item { + id: c1 + objectName: "c1" + property int one: zero + 1 + + Item { + id: c1c1 + objectName: "c1c1" + property bool two: c2c1c1.two + } + + Item { + id: c1c2 + objectName: "c1c2" + property string three: "three" + + Rectangle { + id: c1c2c3 + objectName: "c1c2c3" + property alias othercolor: c2c1.color + color: if (c2c1.color == Qt.rgba(0,0,1)) Qt.rgba(1,0,0); else Qt.rgba(0,1,0); + } + } + } + + Item { + id: c2 + objectName: "c2" + property string two: "two" + + Rectangle { + id: c2c1 + objectName: "c2c1" + property string three: "2" + c1c2.three + color: "blue" + + MouseArea { + id: c2c1c1 + objectName: "c2c1c1" + property bool two: false + onClicked: two = !two + } + + Item { + id: c2c1c2 + objectName: "c2c1c2" + property string three: "1" + parent.three + } + } + } + + Item { + id: c3 + objectName: "c3" + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + } + + property bool success: true + Component.onCompleted: { + // test state after initial bindings evaluation + if (zero != 0) success = false; + if (c1.one != 1) success = false; + if (c1c1.two != false) success = false; + if (c1c2.three != "three") success = false; + if (c1c2c3.color != Qt.rgba(1,0,0)) success = false; + if (c2.two != "two") success = false; + if (c2c1.three != "2three") success = false; + if (c2c1.color != Qt.rgba(0,0,1)) success = false; + if (c2c1c1.two != false) success = false; + if (c2c1c2.three != "12three") success = false; + if (c3.children.length != 500) success = false; + + // now retrigger bindings evaluation + root.zero = 5; + if (c1.one != 6) success = false; + c2c1c1.two = true; + if (c1c1.two != true) success = false; + c1c2.three = "3"; + if (c2c1.three != "23") success = false; + if (c2c1c2.three != "123") success = false; + c2c1.color = Qt.rgba(1,0,0); + if (c1c2c3.color != Qt.rgba(0,1,0)) success = false; + if (c1c2c3.othercolor != Qt.rgba(1,0,0)) success = false; + } +} diff --git a/tests/auto/qml/qqmlcomponent/data/TestComponent.qml b/tests/auto/qml/qqmlcomponent/data/TestComponent.qml new file mode 100644 index 0000000000..64cec1cd06 --- /dev/null +++ b/tests/auto/qml/qqmlcomponent/data/TestComponent.qml @@ -0,0 +1,534 @@ +import QtQuick 2.0 + +Item { + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} +} diff --git a/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro b/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro index cf1c398ce5..6667513395 100644 --- a/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro +++ b/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro @@ -2,7 +2,11 @@ CONFIG += testcase TARGET = tst_qqmlcomponent macx:CONFIG -= app_bundle -SOURCES += tst_qqmlcomponent.cpp +INCLUDEPATH += ../../shared/ +SOURCES += tst_qqmlcomponent.cpp \ + ../../shared/testhttpserver.cpp + +HEADERS += ../../shared/testhttpserver.h include (../../shared/util.pri) @@ -10,4 +14,4 @@ TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private qml-private network testlib +QT += core-private gui-private qml-private quick-private network testlib diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index 603c091a03..10181aa9b8 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -45,8 +45,14 @@ #include #include #include +#include +#include +#include #include #include "../../shared/util.h" +#include "testhttpserver.h" + +#define SERVER_PORT 14450 class MyIC : public QObject, public QQmlIncubationController { @@ -59,6 +65,37 @@ protected: } }; +class ComponentWatcher : public QObject +{ + Q_OBJECT +public: + ComponentWatcher(QQmlComponent *comp) : loading(0), error(0), ready(0) { + connect(comp, SIGNAL(statusChanged(QQmlComponent::Status)), + this, SLOT(statusChanged(QQmlComponent::Status))); + } + + int loading; + int error; + int ready; + +public slots: + void statusChanged(QQmlComponent::Status status) { + switch (status) { + case QQmlComponent::Loading: + ++loading; + break; + case QQmlComponent::Error: + ++error; + break; + case QQmlComponent::Ready: + ++ready; + break; + default: + break; + } + } +}; + class tst_qqmlcomponent : public QQmlDataTest { Q_OBJECT @@ -72,6 +109,8 @@ private slots: void qmlCreateObjectWithProperties(); void qmlIncubateObject(); void qmlCreateParentReference(); + void async(); + void asyncHierarchy(); private: QQmlEngine engine; @@ -213,6 +252,68 @@ void tst_qqmlcomponent::qmlCreateParentReference() QCOMPARE(warnings.count(), 0); } +void tst_qqmlcomponent::async() +{ + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.serveDirectory(dataDirectory()); + + QQmlComponent component(&engine); + ComponentWatcher watcher(&component); + component.loadUrl(QUrl("http://127.0.0.1:14450/TestComponent.qml"), QQmlComponent::Asynchronous); + QCOMPARE(watcher.loading, 1); + QTRY_VERIFY(component.isReady()); + QCOMPARE(watcher.ready, 1); + QCOMPARE(watcher.error, 0); + + QObject *object = component.create(); + QVERIFY(object != 0); + + delete object; +} + +void tst_qqmlcomponent::asyncHierarchy() +{ + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.serveDirectory(dataDirectory()); + + // ensure that the item hierarchy is compiled correctly. + QQmlComponent component(&engine); + ComponentWatcher watcher(&component); + component.loadUrl(QUrl("http://127.0.0.1:14450/TestComponent.2.qml"), QQmlComponent::Asynchronous); + QCOMPARE(watcher.loading, 1); + QTRY_VERIFY(component.isReady()); + QCOMPARE(watcher.ready, 1); + QCOMPARE(watcher.error, 0); + + QObject *root = component.create(); + QVERIFY(root != 0); + + // ensure that the parent-child relationship hierarchy is correct + QQuickItem *c1 = root->findChild("c1", Qt::FindDirectChildrenOnly); + QVERIFY(c1); + QQuickItem *c1c1 = c1->findChild("c1c1", Qt::FindDirectChildrenOnly); + QVERIFY(c1c1); + QQuickItem *c1c2 = c1->findChild("c1c2", Qt::FindDirectChildrenOnly); + QVERIFY(c1c2); + QQuickRectangle *c1c2c3 = c1c2->findChild("c1c2c3", Qt::FindDirectChildrenOnly); + QVERIFY(c1c2c3); + QQuickItem *c2 = root->findChild("c2", Qt::FindDirectChildrenOnly); + QVERIFY(c2); + QQuickRectangle *c2c1 = c2->findChild("c2c1", Qt::FindDirectChildrenOnly); + QVERIFY(c2c1); + QQuickMouseArea *c2c1c1 = c2c1->findChild("c2c1c1", Qt::FindDirectChildrenOnly); + QVERIFY(c2c1c1); + QQuickItem *c2c1c2 = c2c1->findChild("c2c1c2", Qt::FindDirectChildrenOnly); + QVERIFY(c2c1c2); + + // ensure that values and bindings are assigned correctly + QVERIFY(root->property("success").toBool()); + + delete root; +} + QTEST_MAIN(tst_qqmlcomponent) #include "tst_qqmlcomponent.moc" diff --git a/tests/auto/qml/qqmlqt/data/TestComponent.2.qml b/tests/auto/qml/qqmlqt/data/TestComponent.2.qml new file mode 100644 index 0000000000..d6e99028b5 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/TestComponent.2.qml @@ -0,0 +1,592 @@ +import QtQuick 2.0 + +Item { + id: root + objectName: "root" + property int zero: 0 + + Item { + id: c1 + objectName: "c1" + property int one: zero + 1 + + Item { + id: c1c1 + objectName: "c1c1" + property bool two: c2c1c1.two + } + + Item { + id: c1c2 + objectName: "c1c2" + property string three: "three" + + Rectangle { + id: c1c2c3 + objectName: "c1c2c3" + property alias othercolor: c2c1.color + color: if (c2c1.color == Qt.rgba(0,0,1)) Qt.rgba(1,0,0); else Qt.rgba(0,1,0); + } + } + } + + Item { + id: c2 + objectName: "c2" + property string two: "two" + + Rectangle { + id: c2c1 + objectName: "c2c1" + property string three: "2" + c1c2.three + color: "blue" + + MouseArea { + id: c2c1c1 + objectName: "c2c1c1" + property bool two: false + onClicked: two = !two + } + + Item { + id: c2c1c2 + objectName: "c2c1c2" + property string three: "1" + parent.three + } + } + } + + Item { + id: c3 + objectName: "c3" + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + } + + property alias c1one: c1.one + property bool success: true + Component.onCompleted: { + // test state after initial bindings evaluation + if (zero != 0) success = false; + if (c1.one != 1) success = false; + if (c1c1.two != false) success = false; + if (c1c2.three != "three") success = false; + if (c1c2c3.color != Qt.rgba(1,0,0)) success = false; + if (c2.two != "two") success = false; + if (c2c1.three != "2three") success = false; + if (c2c1.color != Qt.rgba(0,0,1)) success = false; + if (c2c1c1.two != false) success = false; + if (c2c1c2.three != "12three") success = false; + if (c3.children.length != 500) success = false; + + // now retrigger bindings evaluation + root.zero = 5; + if (c1.one != 6) success = false; + c2c1c1.two = true; + if (c1c1.two != true) success = false; + c1c2.three = "3"; + if (c2c1.three != "23") success = false; + if (c2c1c2.three != "123") success = false; + c2c1.color = Qt.rgba(1,0,0); + if (c1c2c3.color != Qt.rgba(0,1,0)) success = false; + if (c1c2c3.othercolor != Qt.rgba(1,0,0)) success = false; + } +} diff --git a/tests/auto/qml/qqmlqt/data/TestComponent.3.qml b/tests/auto/qml/qqmlqt/data/TestComponent.3.qml new file mode 100644 index 0000000000..81ea07cb88 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/TestComponent.3.qml @@ -0,0 +1,89 @@ +import QtQuick 2.0 + +Item { + id: root + objectName: "root" + property int zero: 0 + property int one: 1 + + Item { + id: c1 + objectName: "c1" + property int one: zero + parent.one + + Item { + id: c1c1 + objectName: "c1c1" + property bool two: c2c1c1.two + } + + Item { + id: c1c2 + objectName: "c1c2" + property string three: "three" + + Rectangle { + id: c1c2c3 + objectName: "c1c2c3" + property alias othercolor: c2c1.color + color: if (c2c1.color == Qt.rgba(0,0,1)) Qt.rgba(1,0,0); else Qt.rgba(0,1,0); + } + } + } + + Item { + id: c2 + objectName: "c2" + property string two: "two" + + Rectangle { + id: c2c1 + objectName: "c2c1" + property string three: "2" + c1c2.three + color: "blue" + + MouseArea { + id: c2c1c1 + objectName: "c2c1c1" + property bool two: false + onClicked: two = !two + } + + Item { + id: c2c1c2 + objectName: "c2c1c2" + property string three: "1" + parent.three + } + } + } + + property alias c1one: c1.one + property bool success: true + Component.onCompleted: { + // test state after initial bindings evaluation + if (zero != 0) success = false; + if (c1.one != 1) success = false; + if (c1c1.two != false) success = false; + if (c1c2.three != "three") success = false; + if (c1c2c3.color != Qt.rgba(1,0,0)) success = false; + if (c2.two != "two") success = false; + if (c2c1.three != "2three") success = false; + if (c2c1.color != Qt.rgba(0,0,1)) success = false; + if (c2c1c1.two != false) success = false; + if (c2c1c2.three != "12three") success = false; + + // now retrigger bindings evaluation + root.zero = 5; + if (c1.one != 6) success = false; + root.one = 50; + if (c1.one != 55) success = false; + c2c1c1.two = true; + if (c1c1.two != true) success = false; + c1c2.three = "3"; + if (c2c1.three != "23") success = false; + if (c2c1c2.three != "123") success = false; + c2c1.color = Qt.rgba(1,0,0); + if (c1c2c3.color != Qt.rgba(0,1,0)) success = false; + if (c1c2c3.othercolor != Qt.rgba(1,0,0)) success = false; + } +} diff --git a/tests/auto/qml/qqmlqt/data/TestComponent.qml b/tests/auto/qml/qqmlqt/data/TestComponent.qml new file mode 100644 index 0000000000..64cec1cd06 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/TestComponent.qml @@ -0,0 +1,534 @@ +import QtQuick 2.0 + +Item { + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} +} diff --git a/tests/auto/qml/qqmlqt/data/createComponent.2.qml b/tests/auto/qml/qqmlqt/data/createComponent.2.qml new file mode 100644 index 0000000000..36e2b23c9f --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/createComponent.2.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Item { + property bool success: false + property var syncComponent + property var asyncComponent + + function asyncStatusChanged() { + if (asyncComponent.status == Component.Ready && syncComponent.status == Component.Ready) { + success = true; + var ao = asyncComponent.createObject(); + var so = syncComponent.createObject(); + if (ao.c1one != 6) success = false; + if (so.c1one != 55) success = false; + ao.destroy(); + so.destroy(); + } + } + + Component.onCompleted: { + asyncComponent = Qt.createComponent("TestComponent.2.qml", Component.Asynchronous); + if (asyncComponent.status != Component.Loading) + return; + asyncComponent.statusChanged.connect(asyncStatusChanged); + syncComponent = Qt.createComponent("TestComponent.3.qml", Component.PreferSynchronous); + } +} diff --git a/tests/auto/qml/qqmlqt/data/createComponent.qml b/tests/auto/qml/qqmlqt/data/createComponent.qml index 3ebc9f14f8..01b6490419 100644 --- a/tests/auto/qml/qqmlqt/data/createComponent.qml +++ b/tests/auto/qml/qqmlqt/data/createComponent.qml @@ -9,6 +9,14 @@ QtObject { property QtObject incorectArgCount1: Qt.createComponent() property QtObject incorectArgCount2: Qt.createComponent("main.qml", 10) + property bool asyncResult: false + property var asyncComponent + + function asyncStatusChanged() { + if (asyncComponent.status == Component.Ready) + asyncResult = true; + } + Component.onCompleted: { emptyArg = (Qt.createComponent("") == null); var r = Qt.createComponent("createComponentData.qml"); @@ -16,5 +24,10 @@ QtObject { var a = Qt.createComponent("http://www.example.com/test.qml"); absoluteUrl = a.url; + + asyncComponent = Qt.createComponent("TestComponent.qml", Component.Asynchronous); + if (asyncComponent.status != Component.Loading) + return; + asyncComponent.statusChanged.connect(asyncStatusChanged); } } diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp index a679188cb7..d3dc3e7343 100644 --- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp +++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp @@ -395,6 +395,7 @@ void tst_qqmlqt::md5() void tst_qqmlqt::createComponent() { + { QQmlComponent component(&engine, testFileUrl("createComponent.qml")); QString warning1 = component.url().toString() + ":9: Error: Qt.createComponent(): Invalid arguments"; @@ -408,7 +409,19 @@ void tst_qqmlqt::createComponent() QCOMPARE(object->property("absoluteUrl").toString(), QString("http://www.example.com/test.qml")); QCOMPARE(object->property("relativeUrl").toString(), testFileUrl("createComponentData.qml").toString()); + QTRY_VERIFY(object->property("asyncResult").toBool()); + delete object; + } + + // simultaneous sync and async compilation + { + QQmlComponent component(&engine, testFileUrl("createComponent.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QTRY_VERIFY(object->property("success").toBool()); + delete object; + } } void tst_qqmlqt::createComponent_pragmaLibrary() -- cgit v1.2.3 From 21e228afa711ea040170445c649f725bedc394fe Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 14 Mar 2012 16:42:58 +0200 Subject: Windows: Fix file URL issues in declarative autotests Fixed by using testFileUrl() shared utility function where appropriate instead of testFile() or various other ways file URLs were being incorrectly used. Task-number: QTBUG-24779 Change-Id: I48cbd297d419238f42ea45132344b7e5a487b6f1 Reviewed-by: Friedemann Kleint --- tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 3bbbc2c79c..79eaa3316f 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -3112,7 +3112,7 @@ void tst_qqmlecmascript::moduleApi_data() QTest::newRow("qobject, writing + readonly constraints") << testFileUrl("moduleapi/qobjectModuleApiWriting.qml") << QString() - << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/qobjectModuleApiWriting.qml").toLocalFile() + QLatin1String(":15: Error: Cannot assign to read-only property \"qobjectTestProperty\""))) + << (QStringList() << QString(testFileUrl("moduleapi/qobjectModuleApiWriting.qml").toString() + QLatin1String(":15: Error: Cannot assign to read-only property \"qobjectTestProperty\""))) << (QStringList() << "readOnlyProperty" << "writableProperty" << "writableFinalProperty") << (QVariantList() << 20 << 50 << 10) << (QStringList() << "firstProperty" << "secondProperty") @@ -3123,7 +3123,7 @@ void tst_qqmlecmascript::moduleApi_data() QTest::newRow("script, writing + readonly constraints") << testFileUrl("moduleapi/scriptModuleApiWriting.qml") << QString() - << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/scriptModuleApiWriting.qml").toLocalFile() + QLatin1String(":21: Error: Cannot assign to read-only property \"scriptTestProperty\""))) + << (QStringList() << QString(testFileUrl("moduleapi/scriptModuleApiWriting.qml").toString() + QLatin1String(":21: Error: Cannot assign to read-only property \"scriptTestProperty\""))) << (QStringList() << "readBack" << "unchanged") << (QVariantList() << 13 << 42) << (QStringList() << "firstProperty" << "secondProperty") @@ -3232,35 +3232,35 @@ void tst_qqmlecmascript::importScripts_data() QTest::newRow("parent scope shouldn't be inherited by import with imports") << testFileUrl("jsimportfail/failOne.qml") << QString() - << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failOne.qml").toLocalFile() + QLatin1String(":6: TypeError: Cannot call method 'greetingString' of undefined"))) + << (QStringList() << QString(testFileUrl("jsimportfail/failOne.qml").toString() + QLatin1String(":6: TypeError: Cannot call method 'greetingString' of undefined"))) << (QStringList() << QLatin1String("importScriptFunctionValue")) << (QVariantList() << QVariant(QString())); QTest::newRow("javascript imports in an import should be private to the import scope") << testFileUrl("jsimportfail/failTwo.qml") << QString() - << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failTwo.qml").toLocalFile() + QLatin1String(":6: ReferenceError: ImportOneJs is not defined"))) + << (QStringList() << QString(testFileUrl("jsimportfail/failTwo.qml").toString() + QLatin1String(":6: ReferenceError: ImportOneJs is not defined"))) << (QStringList() << QLatin1String("importScriptFunctionValue")) << (QVariantList() << QVariant(QString())); QTest::newRow("module imports in an import should be private to the import scope") << testFileUrl("jsimportfail/failThree.qml") << QString() - << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failThree.qml").toLocalFile() + QLatin1String(":7: TypeError: Cannot read property 'JsQtTest' of undefined"))) + << (QStringList() << QString(testFileUrl("jsimportfail/failThree.qml").toString() + QLatin1String(":7: TypeError: Cannot read property 'JsQtTest' of undefined"))) << (QStringList() << QLatin1String("importedModuleAttachedPropertyValue")) << (QVariantList() << QVariant(false)); QTest::newRow("typenames in an import should be private to the import scope") << testFileUrl("jsimportfail/failFour.qml") << QString() - << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failFour.qml").toLocalFile() + QLatin1String(":6: ReferenceError: JsQtTest is not defined"))) + << (QStringList() << QString(testFileUrl("jsimportfail/failFour.qml").toString() + QLatin1String(":6: ReferenceError: JsQtTest is not defined"))) << (QStringList() << QLatin1String("importedModuleEnumValue")) << (QVariantList() << QVariant(0)); QTest::newRow("import with imports has it's own activation scope") << testFileUrl("jsimportfail/failFive.qml") << QString() - << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importWithImports.js").toLocalFile() + QLatin1String(":8: ReferenceError: Component is not defined"))) + << (QStringList() << QString(testFileUrl("jsimportfail/importWithImports.js").toString() + QLatin1String(":8: ReferenceError: Component is not defined"))) << (QStringList() << QLatin1String("componentError")) << (QVariantList() << QVariant(0)); @@ -3274,7 +3274,7 @@ void tst_qqmlecmascript::importScripts_data() QTest::newRow("pragma library imports shouldn't inherit parent imports or scope") << testFileUrl("jsimportfail/testImportPragmaLibrary.qml") << QString() - << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importPragmaLibrary.js").toLocalFile() + QLatin1String(":6: ReferenceError: Component is not defined"))) + << (QStringList() << QString(testFileUrl("jsimportfail/importPragmaLibrary.js").toString() + QLatin1String(":6: ReferenceError: Component is not defined"))) << (QStringList() << QLatin1String("testValue")) << (QVariantList() << QVariant(0)); -- cgit v1.2.3 From 20ffaaf2977255147ad8a45762d5efb6b5635829 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 14 Mar 2012 11:35:13 +1000 Subject: Fix bug in v4 strict equality. Change-Id: I184065e0b7c8c6536f2081b9bf03e98992a4c9fe Reviewed-by: Roberto Raggi --- tests/auto/qml/v4/data/equals.qml | 48 +++++++++++++++++++++++++++++++++ tests/auto/qml/v4/data/strictEquals.qml | 48 +++++++++++++++++++++++++++++++++ tests/auto/qml/v4/tst_v4.cpp | 2 ++ 3 files changed, 98 insertions(+) create mode 100644 tests/auto/qml/v4/data/equals.qml create mode 100644 tests/auto/qml/v4/data/strictEquals.qml (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/v4/data/equals.qml b/tests/auto/qml/v4/data/equals.qml new file mode 100644 index 0000000000..c32603cc7e --- /dev/null +++ b/tests/auto/qml/v4/data/equals.qml @@ -0,0 +1,48 @@ +import QtQuick 2.0 + +QtObject { + property QtObject myprop1: null + property QtObject myprop2: QtObject {} + property real zero: 0 + property bool falseProp: false + + property bool test1: myprop1 == false + property bool test2: myprop1 == null + property bool test3: 5 == myprop1 + property bool test4: null == myprop1 + property bool test5: myprop1 != false + property bool test6: myprop1 != null + property bool test7: 5 != myprop1 + property bool test8: null != myprop1 + + property bool test9: myprop2 == false + property bool test10: myprop2 == null + property bool test11: 5 == myprop2 + property bool test12: null == myprop2 + property bool test13: myprop2 != false + property bool test14: myprop2 != null + property bool test15: 5 != myprop2 + property bool test16: null != myprop2 + + property bool test17: myprop1 == myprop1 + property bool test18: myprop1 != myprop1 + property bool test19: myprop1 == myprop2 + property bool test20: myprop1 != myprop2 + property bool test21: myprop2 == myprop2 + property bool test22: myprop2 != myprop2 + + property bool test23: myprop1 == "hello" + property bool test24: myprop1 != "hello" + property bool test25: myprop2 == "hello" + property bool test26: myprop2 != "hello" + + property bool test27: falseProp == zero + property bool test28: falseProp != zero + property bool test29: falseProp == 1 + property bool test30: falseProp != 1 + property bool test31: true == zero + property bool test32: true != zero + property bool test33: true == 1 + property bool test34: true != 1 +} + diff --git a/tests/auto/qml/v4/data/strictEquals.qml b/tests/auto/qml/v4/data/strictEquals.qml new file mode 100644 index 0000000000..3f4d0d8b3f --- /dev/null +++ b/tests/auto/qml/v4/data/strictEquals.qml @@ -0,0 +1,48 @@ +import QtQuick 2.0 + +QtObject { + property QtObject myprop1: null + property QtObject myprop2: QtObject {} + property real zero: 0 + property bool falseProp: false + + property bool test1: myprop1 === false + property bool test2: myprop1 === null + property bool test3: 5 === myprop1 + property bool test4: null === myprop1 + property bool test5: myprop1 !== false + property bool test6: myprop1 !== null + property bool test7: 5 !== myprop1 + property bool test8: null !== myprop1 + + property bool test9: myprop2 === false + property bool test10: myprop2 === null + property bool test11: 5 === myprop2 + property bool test12: null === myprop2 + property bool test13: myprop2 !== false + property bool test14: myprop2 !== null + property bool test15: 5 !== myprop2 + property bool test16: null !== myprop2 + + property bool test17: myprop1 === myprop1 + property bool test18: myprop1 !== myprop1 + property bool test19: myprop1 === myprop2 + property bool test20: myprop1 !== myprop2 + property bool test21: myprop2 === myprop2 + property bool test22: myprop2 !== myprop2 + + property bool test23: myprop1 === "hello" + property bool test24: myprop1 !== "hello" + property bool test25: myprop2 === "hello" + property bool test26: myprop2 !== "hello" + + property bool test27: falseProp === zero + property bool test28: falseProp !== zero + property bool test29: falseProp === 1 + property bool test30: falseProp !== 1 + property bool test31: true === zero + property bool test32: true !== zero + property bool test33: true === 1 + property bool test34: true !== 1 +} + diff --git a/tests/auto/qml/v4/tst_v4.cpp b/tests/auto/qml/v4/tst_v4.cpp index ed65cd2a82..1c89617157 100644 --- a/tests/auto/qml/v4/tst_v4.cpp +++ b/tests/auto/qml/v4/tst_v4.cpp @@ -124,6 +124,8 @@ void tst_v4::qtscript_data() { QTest::addColumn("file"); + QTest::newRow("equals") << "equals.qml"; + QTest::newRow("strict equals") << "strictEquals.qml"; QTest::newRow("qreal -> int rounding") << "qrealToIntRounding.qml"; QTest::newRow("exception on fetch") << "fetchException.qml"; QTest::newRow("logical or") << "logicalOr.qml"; -- cgit v1.2.3 From af3a8708b46e8ae6e177dcee028364bd9fd285cd Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 19 Mar 2012 17:37:02 +1000 Subject: When clearing an incubator also clear incubators it is waiting for. If an incubator is cleared while waiting for other incubators to complete also clear the incubators it is waiting for. Change-Id: I83470920c0fd8a23d0098849192555f7478bb492 Reviewed-by: Andrew den Exter --- tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp | 117 +++++++++++++++++++++ 1 file changed, 117 insertions(+) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp index fc54f715c9..54a31aef1d 100644 --- a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp +++ b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp @@ -76,6 +76,7 @@ private slots: void nestedComponent(); void chainedAsynchronousIfNested(); void chainedAsynchronousIfNestedOnCompleted(); + void chainedAsynchronousClear(); void selfDelete(); void contextDelete(); @@ -934,6 +935,122 @@ void tst_qqmlincubator::chainedAsynchronousIfNestedOnCompleted() QVERIFY(incubator3.isReady()); } +// Checks that new AsynchronousIfNested incubators can be correctly cleared if started in +// componentCompleted(). +void tst_qqmlincubator::chainedAsynchronousClear() +{ + SelfRegisteringType::clearMe(); + + QQmlComponent component(&engine, testFileUrl("chainInCompletion.qml")); + QVERIFY(component.isReady()); + + QQmlComponent c1(&engine, testFileUrl("chainedAsynchronousIfNested.qml")); + QVERIFY(c1.isReady()); + + struct MyIncubator : public QQmlIncubator { + MyIncubator(MyIncubator *next, QQmlComponent *component, QQmlContext *ctxt) + : QQmlIncubator(AsynchronousIfNested), next(next), component(component), ctxt(ctxt) {} + + protected: + virtual void statusChanged(Status s) { + if (s == Ready && next) { + component->create(*next, 0, ctxt); + } + } + + private: + MyIncubator *next; + QQmlComponent *component; + QQmlContext *ctxt; + }; + + struct CallbackData { + CallbackData(QQmlComponent *c, MyIncubator *i, QQmlContext *ct) + : component(c), incubator(i), ctxt(ct) {} + QQmlComponent *component; + MyIncubator *incubator; + QQmlContext *ctxt; + static void callback(CompletionCallbackType *, void *data) { + CallbackData *d = (CallbackData *)data; + d->component->create(*d->incubator, 0, d->ctxt); + } + }; + + QQmlIncubator incubator(QQmlIncubator::Asynchronous); + component.create(incubator); + + QVERIFY(incubator.isLoading()); + QVERIFY(SelfRegisteringType::me() == 0); + + while (SelfRegisteringType::me() == 0 && incubator.isLoading()) { + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(SelfRegisteringType::me() != 0); + QVERIFY(incubator.isLoading()); + + MyIncubator incubator3(0, &c1, qmlContext(SelfRegisteringType::me())); + MyIncubator incubator2(&incubator3, &c1, qmlContext(SelfRegisteringType::me())); + MyIncubator incubator1(&incubator2, &c1, qmlContext(SelfRegisteringType::me())); + + // start incubator1 in componentComplete + CallbackData cd(&c1, &incubator1, qmlContext(SelfRegisteringType::me())); + CompletionCallbackType::registerCallback(&CallbackData::callback, &cd); + + while (!incubator1.isLoading()) { + QVERIFY(incubator.isLoading()); + QVERIFY(incubator2.isNull()); + QVERIFY(incubator3.isNull()); + + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(incubator.isLoading()); + QVERIFY(incubator1.isLoading()); + QVERIFY(incubator2.isNull()); + QVERIFY(incubator3.isNull()); + + while (incubator1.isLoading()) { + QVERIFY(incubator.isLoading()); + QVERIFY(incubator1.isLoading()); + QVERIFY(incubator2.isNull()); + QVERIFY(incubator3.isNull()); + + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(incubator.isLoading()); + QVERIFY(incubator1.isReady()); + QVERIFY(incubator2.isLoading()); + QVERIFY(incubator3.isNull()); + + while (incubator2.isLoading()) { + QVERIFY(incubator.isLoading()); + QVERIFY(incubator1.isReady()); + QVERIFY(incubator2.isLoading()); + QVERIFY(incubator3.isNull()); + + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(incubator.isLoading()); + QVERIFY(incubator1.isReady()); + QVERIFY(incubator2.isReady()); + QVERIFY(incubator3.isLoading()); + + // Any in loading state will become null when cleared. + incubator.clear(); + + QVERIFY(incubator.isNull()); + QVERIFY(incubator1.isReady()); + QVERIFY(incubator2.isReady()); + QVERIFY(incubator3.isNull()); +} + void tst_qqmlincubator::selfDelete() { struct MyIncubator : public QQmlIncubator { -- cgit v1.2.3 From cad5df2572d023d1d8ab213d7e736f8d15576916 Mon Sep 17 00:00:00 2001 From: Aurindam Jana Date: Mon, 12 Mar 2012 14:08:56 +0100 Subject: QmlDebugging: Object Tree and States List All created instances are stored under the root context. Check for the creation context of the object when building up the tree. Do the same when building up the states list. Change-Id: I8716d9966a61b8f7cb3ad4b7ab5acd4c94b4cd03 Reviewed-by: Kai Koehne --- .../tst_qqmlenginedebugservice.cpp | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index 9756313905..e409f3c8b6 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -137,11 +137,15 @@ QQmlDebugObjectReference tst_QQmlEngineDebugService::findRootObject(int context, QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this); waitForQuery(q_context); - if (q_context->rootContext().objects().count() == 0) + if (q_context->rootContext().contexts().count() == 0 || + q_context->rootContext().contexts().last().objects().count() == 0) return QQmlDebugObjectReference(); + + //Contexts are in a stack + int count = q_context->rootContext().contexts().count(); QQmlDebugObjectQuery *q_obj = recursive ? - m_dbg->queryObjectRecursive(q_context->rootContext().objects()[context], this) : - m_dbg->queryObject(q_context->rootContext().objects()[context], this); + m_dbg->queryObjectRecursive(q_context->rootContext().contexts()[count - context - 1].objects()[0], this) : + m_dbg->queryObject(q_context->rootContext().contexts()[count - context - 1].objects()[0], this); waitForQuery(q_obj); QQmlDebugObjectReference result = q_obj->object(); @@ -493,8 +497,9 @@ void tst_QQmlEngineDebugService::watch_object() QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this); waitForQuery(q_context); - QVERIFY(q_context->rootContext().objects().count() > 0); - QQmlDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this); + QVERIFY(q_context->rootContext().contexts().count()); + QVERIFY(q_context->rootContext().contexts().last().objects().count() > 0); + QQmlDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().contexts().last().objects()[0], this); waitForQuery(q_obj); QQmlDebugObjectReference obj = q_obj->object(); @@ -705,12 +710,9 @@ void tst_QQmlEngineDebugService::queryRootContexts() QCOMPARE(context.debugId(), QQmlDebugService::idForObject(actualContext)); QCOMPARE(context.name(), actualContext->objectName()); - QCOMPARE(context.objects().count(), 4); // 4 qml component objects created for context in main() - // root context query sends only root object data - it doesn't fill in // the children or property info - QCOMPARE(context.objects()[0].properties().count(), 0); - QCOMPARE(context.objects()[0].children().count(), 0); + QCOMPARE(context.objects().count(), 0); QCOMPARE(context.contexts().count(), 5); QVERIFY(context.contexts()[0].debugId() >= 0); @@ -734,7 +736,7 @@ void tst_QQmlEngineDebugService::queryObject() QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this); waitForQuery(q_context); - QQmlDebugObjectReference rootObject = q_context->rootContext().objects()[0]; + QQmlDebugObjectReference rootObject = q_context->rootContext().contexts().last().objects()[0]; QQmlDebugObjectQuery *q_obj = 0; @@ -815,7 +817,7 @@ void tst_QQmlEngineDebugService::queryExpressionResult() QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this); waitForQuery(q_context); - int objectId = q_context->rootContext().objects()[0].debugId(); + int objectId = q_context->rootContext().contexts().last().objects()[0].debugId(); QQmlDebugExpressionQuery *q_expr; @@ -1164,8 +1166,9 @@ void tst_QQmlEngineDebugService::queryObjectTree() QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this); waitForQuery(q_context); - QVERIFY(q_context->rootContext().objects().count() > sourceIndex); - QQmlDebugObjectReference rootObject = q_context->rootContext().objects()[sourceIndex]; + QVERIFY(q_context->rootContext().contexts().count() >= sourceIndex); + int count = q_context->rootContext().contexts().count(); + QQmlDebugObjectReference rootObject = q_context->rootContext().contexts()[count - sourceIndex - 1].objects()[0]; QQmlDebugObjectQuery *q_obj = m_dbg->queryObjectRecursive(rootObject, this); waitForQuery(q_obj); -- cgit v1.2.3