From 9035d1cb2a474a6df52ca395e6c185964ec94de0 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 17 Jun 2025 14:15:02 +0200 Subject: QmlCompiler: Restore support for writing to temporary arrays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We use the JavaScript extension as "read" type to signify that the code generator will accept any type with such an extension. This requires some adjustments in the type resolver. Pick-to: 6.10 6.9 6.8 6.5 Task-number: QTBUG-137540 Change-Id: Ia34ca0a24c417c5372852268ba2f55825484639d Reviewed-by: Olivier De Cannière --- 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 ffd18f09a7..b322f870fa 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -288,6 +288,7 @@ private slots: void voidFunction(); void writeBack(); void writeVariantMap(); + void writeAndReturnTempArray(); }; static QByteArray arg1() @@ -5838,6 +5839,20 @@ void tst_QmlCppCodegen::writeVariantMap() } +void tst_QmlCppCodegen::writeAndReturnTempArray() +{ + QQmlEngine engine; + QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/Categorizer.qml"_s)); + + QVERIFY2(component.isReady(), qPrintable(component.errorString())); + QScopedPointer object(component.create()); + QVERIFY(!object.isNull()); + + const QVariant nnn = object->property("nnn"); + QCOMPARE(nnn.metaType(), QMetaType::fromType>()); + QCOMPARE(nnn.value>(), QList{10}); +} + QTEST_MAIN(tst_QmlCppCodegen) #include "tst_qmlcppcodegen.moc" -- cgit v1.2.3