aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2025-06-26 15:05:52 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2025-06-26 20:36:14 +0200
commit69fb18357c8495b58dba04960629f1f21eed3618 (patch)
treec3a0b2e6dca860e5978112edd487e266d9e84834 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parent7b44231f33959a40684aebefcf6473a5339ef445 (diff)
compiler: Avoid invalid C++ code generation
inlineConsoleMethod's stringConversion needs to create a string, so that we can later append to it. Because we were missing parentheses, this did not happen, and we would end up with code looking like u']'.append(...) which obviously isn't valid C++. Fix this by always adding parentheses around the expression. Found while trying to prove that QTBUG-109279 was fixed. Task-number: QTBUG-109279 Pick-to: 6.10 6.9 Change-Id: I67fce5b2c1f1460a5d6b617824f3c36f9804ea76 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.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 708e835f46..00c00b4c0f 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -1223,13 +1223,18 @@ void tst_QmlCppCodegen::consoleObject()
const QRegularExpression re2(u"QQmlComponentAttached\\(0x[0-9a-f]+\\)"_s);
QTest::ignoreMessage(QtDebugMsg, re2);
+ QTest::ignoreMessage(QtDebugMsg, "[1,2,3,4,5] true");
+
QScopedPointer<QObject> o(c.create());
QVERIFY(!o.isNull());
auto oldHandler = qInstallMessageHandler(
- [](QtMsgType, const QMessageLogContext &ctxt, const QString &) {
+ [](QtMsgType, const QMessageLogContext &ctxt, const QString &msg) {
QCOMPARE(ctxt.file, urlString.toUtf8());
- QCOMPARE(ctxt.function, QByteArray("expression for onCompleted"));
+ if (msg == QString(u"[1,2,3,4,5] true"))
+ QCOMPARE(ctxt.function, QByteArray("xyz"));
+ else
+ QCOMPARE(ctxt.function, QByteArray("expression for onCompleted"));
QVERIFY(ctxt.line > 0);
});
const auto guard = qScopeGuard([oldHandler]() { qInstallMessageHandler(oldHandler); });