From 4a5b989755cc7e92a3d9045c37d272ee114c702a Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 8 Apr 2021 13:50:46 +0200 Subject: Do not auto-clean components with live inline components The inline components do not hold a strong reference to their outer type because that would be a reference cycle. Fixes: QTBUG-92236 Change-Id: I6d76a114352653210f0ece6c198cf761d3b4eda1 Reviewed-by: Fabian Kosmale (cherry picked from commit d0d4cc528ba9e3c39c15a2292066dac1d457abd5) --- tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp') diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index e247a139ec..de8b2ef7eb 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include "testtypes.h" #include "testhttpserver.h" @@ -331,6 +332,7 @@ private slots: void arrayToContainer(); void qualifiedScopeInCustomParser(); void accessNullPointerPropertyCache(); + void bareInlineComponent(); private: QQmlEngine engine; @@ -5813,6 +5815,32 @@ void tst_qqmllanguage::accessNullPointerPropertyCache() QVERIFY(!obj.isNull()); } +void tst_qqmllanguage::bareInlineComponent() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("bareInline.qml")); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer o(c.create()); + QVERIFY(!o.isNull()); + + QQmlMetaType::freeUnusedTypesAndCaches(); + + bool tab1Found = false; + const auto types = QQmlMetaType::qmlTypes(); + for (const QQmlType &type : types) { + if (type.elementName() == QStringLiteral("Tab1")) { + QVERIFY(type.module().isEmpty()); + tab1Found = true; + const auto ics = type.priv()->objectIdToICType; + QVERIFY(ics.size() > 0); + for (const QQmlType &ic : ics) + QVERIFY(ic.containingType() == type); + } + } + QVERIFY(tab1Found); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" -- cgit v1.2.3