diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-07-15 10:42:48 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-07-22 09:57:06 +0200 |
commit | b4d36a05be9f34976c1a1b5ea60ce03c4ab59a25 (patch) | |
tree | 7d36017ebaf03abd9af674d921bb9dbc24e41a81 /tests/auto/qml | |
parent | 682a87a637eab8f7d6bb671e7b681dcaf227a15b (diff) |
QQmlIRLoader: Restore inline components correctly
Whether a component is an inline component is not only stored in the
flags, but also in the isInlineComponent member.
Ideally, this should be unified and the member removed, but for now we
just restore the value correctly.
Adjusted tst_qmlcachegen::initTestCase so that we testFile and
testFileUrl are actually usable in the test.
Fixes: QTBUG-84237
Pick-to: 5.15
Change-Id: I759cd6b8914b186b9e5c8118863fc8d0580d21af
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/qml')
-rw-r--r-- | tests/auto/qml/qmlcachegen/data/inlineComponentWithId.qml | 10 | ||||
-rw-r--r-- | tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp | 14 |
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcachegen/data/inlineComponentWithId.qml b/tests/auto/qml/qmlcachegen/data/inlineComponentWithId.qml new file mode 100644 index 0000000000..ef9a157e5e --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/inlineComponentWithId.qml @@ -0,0 +1,10 @@ +import QtQuick 2.15 + +Item { + component Test: Item { + id: test + property int t: 42 + Component.onCompleted: console.info(test.t) + } + Test {} +} diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp index 652942b243..283aef9317 100644 --- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp +++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp @@ -76,6 +76,7 @@ private slots: void reproducibleCache(); void parameterAdjustment(); + void inlineComponent(); }; // A wrapper around QQmlComponent to ensure the temporary reference counts @@ -129,6 +130,7 @@ void tst_qmlcachegen::initTestCase() if (!cacheDir.isEmpty()) //QDir(cacheDir).removeRecursively(); qDebug() << cacheDir; + QQmlDataTest::initTestCase(); } void tst_qmlcachegen::loadGeneratedFile() @@ -690,6 +692,18 @@ void tst_qmlcachegen::parameterAdjustment() QVERIFY(!obj.isNull()); // Doesn't crash } + +void tst_qmlcachegen::inlineComponent() +{ + bool ok = generateCache(testFile("inlineComponentWithId.qml")); + QVERIFY(ok); + QQmlEngine engine; + CleanlyLoadingComponent component(&engine, testFileUrl("inlineComponentWithId.qml")); + QTest::ignoreMessage(QtMsgType::QtInfoMsg, "42"); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); +} + QTEST_GUILESS_MAIN(tst_qmlcachegen) #include "tst_qmlcachegen.moc" |