aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2025-06-20 11:57:49 +0200
committerUlf Hermann <ulf.hermann@qt.io>2025-06-23 15:44:38 +0200
commit32602bef7c40261cbe61d72e8cf043feb3734d3e (patch)
tree08b937c68891fcfff999ebd939feedb71699e27b /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parent9035d1cb2a474a6df52ca395e6c185964ec94de0 (diff)
QmlCompiler: Sharpen side effect detection
Stack-created lists of primitives or pointers cannot be affected by side effects. We cannot write a value affected by side effects to a list that isn't, though. Pick-to: 6.10 6.9 6.8 6.5 Task-number: QTBUG-137540 Change-Id: I99ab4337cabc6111a81b8164fd94962edc0db25e Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index b322f870fa..5ec98cbdaf 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -5670,8 +5670,16 @@ void tst_QmlCppCodegen::valueTypeBehavior()
void tst_QmlCppCodegen::valueTypeLists()
{
QQmlEngine engine;
- QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/valueTypeLists.qml"_s));
+ const QUrl url(u"qrc:/qt/qml/TestTypes/valueTypeLists.qml"_s);
+ QQmlComponent c(&engine, url);
QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+
+ const QString bindingLoop = url.toString()
+ + uR"(:3:1: QML QObject*: Binding loop detected for property "rectList2":
+qrc:/qt/qml/TestTypes/valueTypeLists.qml:19:5)"_s;
+ for (int i = 0; i < 2; ++i)
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(bindingLoop));
+
QScopedPointer<QObject> o(c.create());
QCOMPARE(qvariant_cast<QRectF>(o->property("rectInBounds")), QRectF(1, 2, 3, 4));
@@ -5689,6 +5697,10 @@ void tst_QmlCppCodegen::valueTypeLists()
QCOMPARE(qvariant_cast<QString>(o->property("charInBounds")), QStringLiteral("d"));
QVERIFY(o->metaObject()->indexOfProperty("charOutOfBounds") > 0);
QVERIFY(!o->property("charOutOfBounds").isValid());
+
+ const QList<QRectF> rectList = o->property("rectList2").value<QList<QRectF>>();
+ QCOMPARE(rectList.length(), 1);
+ QCOMPARE(rectList[0], QRectF(666, 13, 14, 15));
}
void tst_QmlCppCodegen::valueTypeProperty()
@@ -5851,6 +5863,13 @@ void tst_QmlCppCodegen::writeAndReturnTempArray()
const QVariant nnn = object->property("nnn");
QCOMPARE(nnn.metaType(), QMetaType::fromType<QList<double>>());
QCOMPARE(nnn.value<QList<double>>(), QList<double>{10});
+
+ const QVariant numbers = object->property("numbers");
+ QCOMPARE(numbers.metaType(), QMetaType::fromType<QList<double>>());
+ const QList<double> numbersContent = numbers.value<QList<double>>();
+ QCOMPARE(numbersContent.length(), 32);
+ for (double number: std::as_const(numbersContent))
+ QVERIFY(number >= 0 && number < double(0xf0f0f0));
}
QTEST_MAIN(tst_QmlCppCodegen)