diff options
| author | Olivier De Cannière <olivier.decanniere@qt.io> | 2024-07-16 10:29:43 +0200 |
|---|---|---|
| committer | Olivier De Cannière <olivier.decanniere@qt.io> | 2024-07-17 12:14:46 +0200 |
| commit | 179581e16fdcb071cec40cd7189251ea9ac08d10 (patch) | |
| tree | 04d1d24369a4d64a897927d6d4dc341740625938 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | 03d07d83c7b6316ac3a804f321a6fe70c27d7a21 (diff) | |
Compiler: Properly read value type arguments when enforcing signatures
The patch that introduces the enforcing of signature types did so by
passing the contained rather than the stored metatypes for the
arguments.
These types are used to populate the registers of the function with the
arguments using the proper types by static_cast'ing the void* arguments
to the actual types.
However, for value types, the arguments were assumed to be QVariants and
were thus casted to one even though they were actually passed as the
actual argument type. This seems to have been mostly fine by accident
because of the inline storage of QVariant that lays at offset 0 in its
layout. Therefore, if the flag signalling that the value is actually
elsewhere was not set to 1 by the casting and the value fit in the
inline storage everything would still work. This is not always the case
however and can lead to crashes.
Therefore, treat value type arguments as plain non-wrapped values when
populating function arguments.
Amends 8bf5aae19b77b618f3f7a55a59e87c8a319475a8
Fixes: QTBUG-127009
Pick-to: 6.8
Change-Id: I495bcff7631399f207d87fea698d7e921e8e4721
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 5505e30e3b..e5e30e0210 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -248,6 +248,7 @@ private slots: void unstoredUndefined(); void unusedAttached(); void urlString(); + void valueTypeArgument(); void valueTypeBehavior(); void valueTypeLists(); void valueTypeProperty(); @@ -4956,6 +4957,18 @@ void tst_QmlCppCodegen::urlString() QCOMPARE(rootObject->objectName(), QLatin1String("http://dddddd.com")); } +void tst_QmlCppCodegen::valueTypeArgument() +{ + QTest::ignoreMessage(QtMsgType::QtDebugMsg, "Reading l.i=5"); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/ValueTypeArgument.qml"_s)); + + QVERIFY2(component.isReady(), qPrintable(component.errorString())); + QScopedPointer<QObject> rootObject(component.create()); + QVERIFY(rootObject); +} + void tst_QmlCppCodegen::valueTypeBehavior() { QQmlEngine engine; |
