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/data | |
| 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/data')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/ValueTypeArgument.qml | 21 | ||||
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/largeValueType.h | 15 |
3 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt index 889edbe0a6..4a113fb964 100644 --- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt +++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt @@ -14,6 +14,7 @@ set(cpp_sources getOptionalLookup.h gadgetwithenum.h invisible.h + largeValueType.h listprovider.h multiforeign.h objectwithmethod.h @@ -73,6 +74,7 @@ set(qml_files StoreMetaEnum.qml Test.qml TestCase.qml + ValueTypeArgument.qml Variable.qml WindowDerived.qml aliasLookup.qml diff --git a/tests/auto/qml/qmlcppcodegen/data/ValueTypeArgument.qml b/tests/auto/qml/qmlcppcodegen/data/ValueTypeArgument.qml new file mode 100644 index 0000000000..5da1b253e0 --- /dev/null +++ b/tests/auto/qml/qmlcppcodegen/data/ValueTypeArgument.qml @@ -0,0 +1,21 @@ +pragma Strict + +import QtQml +import TestTypes + +QtObject { + id: root + property largeValueType l + + function callee(l: largeValueType) : void { + console.log("Reading l.i=" + l.i) + } + + function caller() : void { + callee(root.l) + } + + Component.onCompleted: { + caller() + } +} diff --git a/tests/auto/qml/qmlcppcodegen/data/largeValueType.h b/tests/auto/qml/qmlcppcodegen/data/largeValueType.h new file mode 100644 index 0000000000..028a5f690f --- /dev/null +++ b/tests/auto/qml/qmlcppcodegen/data/largeValueType.h @@ -0,0 +1,15 @@ +#include <qqmlintegration.h> +#include <qqml.h> + +class LargeValueType +{ + Q_GADGET + QML_VALUE_TYPE(largeValueType) + Q_PROPERTY(int i READ i) + +private: + int i() const { return m_i; } + + char m_probablyDefinitelyBiggerThanQVariantInlineStorage[2048]{}; + int m_i = 5; +}; |
