From c36416c9713f9ac98529affadf07b05d8b6ae95e Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 28 Mar 2025 09:20:09 +0100 Subject: QmlCompiler: Do not re-resolve iterator value types We've resolved the value type in the type propagator. Trying to do it again in the code generator, after the iterator may have been adjusted, is quite wrong. If we resolve the list value type on a type that's not a list (anymore), then we get an invalid type, which subsequently crashes. Amends commit a173d50a9e54d2a21a5207f6c66bb54bb8f3a612. Pick-to: 6.9 6.8 Fixes: QTBUG-135288 Change-Id: I1227803ed100c83f8fc11898be0a4d0199d639dd Reviewed-by: Fabian Kosmale --- tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 15 +++++++++++++++ 1 file changed, 15 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 9ac9898ed0..9dd3016809 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -157,6 +157,7 @@ private slots: void invisibleListElementType(); void invisibleSingleton(); void invisibleTypes(); + void iterateUnknownValue(); void iteration(); void javaScriptArgument(); void jsArrayMethods(); @@ -2925,6 +2926,20 @@ void tst_QmlCppCodegen::invisibleTypes() // QCOMPARE(meta->className(), "DerivedFromInvisible"); } +void tst_QmlCppCodegen::iterateUnknownValue() +{ + QQmlEngine engine; + QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/iterateUnknownValue.qml"_s)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + + QTest::ignoreMessage(QtDebugMsg, "one"); + QTest::ignoreMessage(QtDebugMsg, "two"); + QTest::ignoreMessage(QtDebugMsg, "three"); + + QScopedPointer o(c.create()); + QVERIFY(!o.isNull()); +} + void tst_QmlCppCodegen::iteration() { QQmlEngine engine; -- cgit v1.2.3