From 6b14ba5c2fbc2810bb62a87008e338cca571acf6 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 20 Jun 2025 13:17:31 +0200 Subject: QmlCompiler: Discern between different kinds of side effects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A mere jump does not cause all value types and lists to be invalidated. Only calls to other functions or writes to other properties do that. Pick-to: 6.10 6.9 6.8 6.5 Fixes: QTBUG-137540 Change-Id: I069c6873455c51bbea59cf876d2bc7ecd188f81b Reviewed-by: Olivier De Cannière --- tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 19 +++++++++++++++++++ 1 file changed, 19 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 5ec98cbdaf..708e835f46 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -5870,6 +5870,25 @@ void tst_QmlCppCodegen::writeAndReturnTempArray() QCOMPARE(numbersContent.length(), 32); for (double number: std::as_const(numbersContent)) QVERIFY(number >= 0 && number < double(0xf0f0f0)); + + QList expected { 0, 0, 0, 0}; + for (int i = 0; i < 2; ++i) { + for (double number : std::as_const(numbersContent)) { + const int num = QJSNumberCoercion::toInteger((number)) & 0xabcdef; + if (num < 0xf0f) + expected[0] += num; + else if (num < 0xf0f0) + expected[1] += num; + else if (num < 0xf0f0f) + expected[2] += num; + else + expected[3] += num; + } + } + + QList sum; + QMetaObject::invokeMethod(object.data(), "sum", Q_RETURN_ARG(QList, sum)); + QCOMPARE(sum, expected); } QTEST_MAIN(tst_QmlCppCodegen) -- cgit v1.2.3