diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-08-05 21:10:17 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-08-06 06:25:06 +0000 |
commit | a3aad1a470dc9cb1feea7c6b3bf35f725a6b898d (patch) | |
tree | 3c0436f3c92b7dd71875bf409b3fae17b6a43e39 /tests/auto/qml/qmldiskcache | |
parent | 8d1bae4c0f45ea6853d5ff63fda4f625f1e4bb83 (diff) |
Fix restoring of local aliases from disk cache
Local aliases are always "resolved". We must be careful not to access
the same field in the union otherwise and mistake it as property index.
Change-Id: I6369cdba145a62dcdaa10d8f4ee84bfa3cbfa0e3
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/qml/qmldiskcache')
-rw-r--r-- | tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp index c3a80eebde..dd23dfca07 100644 --- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp +++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp @@ -51,6 +51,7 @@ private slots: void basicVersionChecks(); void recompileAfterChange(); void fileSelectors(); + void localAliases(); }; // A wrapper around QQmlComponent to ensure the temporary reference counts @@ -485,6 +486,49 @@ void tst_qmldiskcache::fileSelectors() } } +void tst_qmldiskcache::localAliases() +{ + QQmlEngine engine; + + TestCompiler testCompiler(&engine); + QVERIFY(testCompiler.tempDir.isValid()); + + const QByteArray contents = QByteArrayLiteral("import QtQml 2.0\n" + "QtObject {\n" + " id: root\n" + " property int prop: 100\n" + " property alias dummy1: root.prop\n" + " property alias dummy2: root.prop\n" + " property alias dummy3: root.prop\n" + " property alias dummy4: root.prop\n" + " property alias dummy5: root.prop\n" + " property alias foo: root.prop\n" + " property alias bar: root.foo\n" + "}"); + + { + testCompiler.clearCache(); + QVERIFY2(testCompiler.compile(contents), qPrintable(testCompiler.lastErrorString)); + QVERIFY2(testCompiler.verify(), qPrintable(testCompiler.lastErrorString)); + } + + { + CleanlyLoadingComponent component(&engine, testCompiler.testFilePath); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QCOMPARE(obj->property("bar").toInt(), 100); + } + + engine.clearComponentCache(); + + { + CleanlyLoadingComponent component(&engine, testCompiler.testFilePath); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QCOMPARE(obj->property("bar").toInt(), 100); + } +} + QTEST_MAIN(tst_qmldiskcache) #include "tst_qmldiskcache.moc" |