From 75dcbb156b2b1dfe0bb43e3119735f26f848e0f6 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 10 Oct 2025 10:47:46 +0200 Subject: QtQml: Fix resolution of aliases to local aliases When we find an alias to a local alias, we need to first check if the target alias is already resolved. Otherwise we can't insert the source alias, yet. Amends commit 9e1378260a3f3a6eb4cad8d6ae47bc218e6a2b5f. Pick-to: 6.10 Fixes: QTBUG-141059 Change-Id: If272a746595b39cb2dbc2b8cc0c2f688277cfe59 Reviewed-by: Fabian Kosmale --- tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp') diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 86e6c4cd16..aa76b8cd50 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -48,6 +48,7 @@ private slots: void accessModelMethodFromOutSide(); void aliasLookup(); void aliasToAliasResolutionSkipCorruption(); + void aliasToLocalAlias(); void ambiguousAs(); void ambiguousSignals(); void anchorsFill(); @@ -610,6 +611,27 @@ void tst_QmlCppCodegen::aliasToAliasResolutionSkipCorruption() QVERIFY(!object.isNull()); } +void tst_QmlCppCodegen::aliasToLocalAlias() +{ + QQmlEngine engine; + QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/aliasToLocalAlias.qml"_s)); + QVERIFY2(!component.isError(), component.errorString().toUtf8()); + QScopedPointer object(component.create()); + QVERIFY(!object.isNull()); + + const QVariant label = object->property("label"); + QCOMPARE(label.metaType(), QMetaType::fromType()); + QVERIFY(label.toString().isEmpty()); + + const QVariant description = object->property("description"); + QCOMPARE(description.metaType(), QMetaType::fromType()); + QVERIFY(description.toString().isEmpty()); + + object->setObjectName(u"nnn"); + QCOMPARE(object->property("label").toString(), u"nnn"); + QCOMPARE(object->property("description").toString(), u"nnn"); +} + void tst_QmlCppCodegen::ambiguousAs() { QQmlEngine e; -- cgit v1.2.3