aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmldiskcache
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2024-04-03 17:55:45 +0200
committerUlf Hermann <ulf.hermann@qt.io>2024-04-05 20:38:07 +0200
commitb91a26ae3b7b2ab68128f41db6ed4ccf7366dfc4 (patch)
tree172c9daaef074f9a875fb9aca8cc5ff938ccf0e4 /tests/auto/qml/qmldiskcache
parent4b5f091c499b5aad66a8b39fcdab8f80d986a1f8 (diff)
QtQml: Resolve generalized group properties during alias resolution
This way we can know the scope in which to search for the IDs. Pick-to: 6.7 6.5 Fixes: QTBUG-123865 Change-Id: I1dff9bdc69e3edaa80d85c757e3bb2b24e174cd0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmldiskcache')
-rw-r--r--tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
index c1df8ec467..810fdecafd 100644
--- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
+++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
@@ -42,6 +42,7 @@ private slots:
void cacheModuleScripts();
void reuseStaticMappings();
void invalidateSaveLoadCache();
+ void duplicateIdsInInlineComponents();
void inlineComponentDoesNotCauseConstantInvalidation_data();
void inlineComponentDoesNotCauseConstantInvalidation();
@@ -1186,6 +1187,77 @@ void tst_qmldiskcache::invalidateSaveLoadCache()
QVERIFY(unit->unitData() != oldUnit->unitData());
}
+void tst_qmldiskcache::duplicateIdsInInlineComponents()
+{
+ // Exercise the case of loading strange generalized group properties from .qmlc.
+
+ QQmlEngine engine;
+
+ TestCompiler testCompiler(&engine);
+ QVERIFY(testCompiler.tempDir.isValid());
+
+ const QByteArray contents = QByteArrayLiteral(R"(
+ import QtQml
+ QtObject {
+ component First : QtObject {
+ property QtObject aa: QtObject {
+ id: a
+ }
+ property Binding bb: Binding {
+ a.objectName: "test1"
+ }
+ }
+
+ component Second : QtObject {
+ property QtObject aa: QtObject {
+ id: a
+ }
+ property Binding bb: Binding {
+ a.objectName: "test2"
+ }
+
+ property Component cc: QtObject {
+ property QtObject aa: QtObject {
+ id: a
+ }
+ property Binding bb: Binding {
+ a.objectName: "test3"
+ }
+ }
+ }
+
+ property First first: First {}
+ property Second second: Second {}
+ property QtObject third: second.cc.createObject();
+
+ objectName: first.aa.objectName + second.aa.objectName + third.aa.objectName;
+ }
+ )");
+
+ {
+ 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->objectName(), "test1test2test3");
+ }
+
+ engine.clearComponentCache();
+
+ {
+ CleanlyLoadingComponent component(&engine, testCompiler.testFilePath);
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+ QCOMPARE(obj->objectName(), "test1test2test3");
+ }
+}
+
void tst_qmldiskcache::inlineComponentDoesNotCauseConstantInvalidation_data()
{
QTest::addColumn<QByteArray>("code");