aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2026-03-12 13:59:17 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2026-03-13 21:12:35 +0000
commit5d5825f097042b52c4e6007148d364608105a460 (patch)
tree8c300d4fe6acb1972a359fab81c4fc834b166f73
parent2d9cac34588824765a2e697731d54b686e14937e (diff)
QmlCompiler: Honor isList flag when process deferred property types
If the property has the isList flag, we want the list type, not the plain type. Pick-to: 6.8 Fixes: QTBUG-144810 Change-Id: Ifdcdc1a0c40f39aceaa2ef522eb12e90664e57c4 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> (cherry picked from commit 954b73a93f18474cfa5f811282e70a4292d7cb92) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 7f832fce871b4f750fa2a8959f9f525f6f7e992c)
-rw-r--r--src/qmlcompiler/qqmljsimportvisitor.cpp2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt1
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/listOfInlineComponent.qml15
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp14
4 files changed, 31 insertions, 1 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp
index 34e007126c..86f38bd9d7 100644
--- a/src/qmlcompiler/qqmljsimportvisitor.cpp
+++ b/src/qmlcompiler/qqmljsimportvisitor.cpp
@@ -837,7 +837,7 @@ void QQmlJSImportVisitor::processPropertyTypes()
if (const auto propertyType = QQmlJSScope::findType(
property.typeName(), m_rootScopeImports.contextualTypes()).scope) {
- property.setType(propertyType);
+ property.setType(property.isList() ? propertyType->listType() : propertyType);
type.scope->addOwnProperty(property);
} else {
QString msg = property.typeName() + ' '_L1 + wasNotFound + ' '_L1 + didYouAddAllImports;
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
index 86968e6167..dda0548a7e 100644
--- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
+++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
@@ -239,6 +239,7 @@ set(qml_files
listAsArgument.qml
listConversion.qml
listIndices.qml
+ listOfInlineComponent.qml
listOfInvisible.qml
listPropertyAsModel.qml
listToString.qml
diff --git a/tests/auto/qml/qmlcppcodegen/data/listOfInlineComponent.qml b/tests/auto/qml/qmlcppcodegen/data/listOfInlineComponent.qml
new file mode 100644
index 0000000000..1f70ee9e0b
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/listOfInlineComponent.qml
@@ -0,0 +1,15 @@
+import QtQml
+
+QtObject {
+ id: root
+
+ // NOTE: No crash if:
+ // - We use list<QtObject> instead of list<QMLType>, OR
+ // - We set NO_CACHEGEN in qt_add_qml_module(), OR
+ // - We use Windows instead of macOS, OR
+ // - We swap the two lines below
+ property list<QMLType> qmlTypeList
+ component QMLType: QtObject {}
+
+ property var model: root.qmlTypeList
+}
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index fbb698349b..8019a48806 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -195,6 +195,7 @@ private slots:
void listIndices();
void listLength();
void listOfInvisible();
+ void listOfInlineComponent();
void listPropertyAsModel();
void listToString();
void lotsOfRegisters();
@@ -3834,6 +3835,19 @@ void tst_QmlCppCodegen::listOfInvisible()
QCOMPARE(object->property("width").toDouble(), 27.0);
}
+void tst_QmlCppCodegen::listOfInlineComponent()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/listOfInlineComponent.qml"_s));
+ QVERIFY2(component.isReady(), component.errorString().toUtf8());
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(!object.isNull());
+ const QVariant model = object->property("model");
+ QCOMPARE(model.metaType(), QMetaType::fromType<QQmlListReference>());
+ QQmlListReference ref = model.value<QQmlListReference>();
+ QCOMPARE(ref.count(), 0);
+}
+
void tst_QmlCppCodegen::listPropertyAsModel()
{
QQmlEngine engine;