diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-07-15 10:42:48 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-07-22 09:29:58 +0000 |
commit | ec1fc3aaa78c2c6a8ed660f26bc2c26b7d0c10bb (patch) | |
tree | fc7060726243db6f35e330dc015611efd4a43bad | |
parent | a99fa4cb4ca1f834235a819bb823b135d0d0203a (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
Change-Id: I759cd6b8914b186b9e5c8118863fc8d0580d21af
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit b4d36a05be9f34976c1a1b5ea60ce03c4ab59a25)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/qml/qml/qqmlirloader.cpp | 1 | ||||
-rw-r--r-- | tests/auto/qml/qmlcachegen/data/inlineComponentWithId.qml | 10 | ||||
-rw-r--r-- | tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp | 14 |
3 files changed, 25 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlirloader.cpp b/src/qml/qml/qqmlirloader.cpp index f66094fad7..5609ba8aa8 100644 --- a/src/qml/qml/qqmlirloader.cpp +++ b/src/qml/qml/qqmlirloader.cpp @@ -95,6 +95,7 @@ QmlIR::Object *QQmlIRLoader::loadObject(const QV4::CompiledData::Object *seriali object->indexOfDefaultPropertyOrAlias = serializedObject->indexOfDefaultPropertyOrAlias; object->defaultPropertyIsAlias = serializedObject->defaultPropertyIsAlias; + object->isInlineComponent = serializedObject->flags & QV4::CompiledData::Object::IsInlineComponentRoot; object->flags = serializedObject->flags; object->id = serializedObject->id; object->location = serializedObject->location; 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 3a97f50296..c5602eda7d 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() @@ -687,6 +689,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" |