aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-06-23 08:56:42 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-06-23 21:06:50 +0000
commit9b22095657b8b1c3fb01f529a3ae2e663eb86ab9 (patch)
treef9f114d918ebffb0ec085d95f6ad048a850c407e /tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
parent06b2fd7bc998f111b549fbee066352e74c9cb89d (diff)
tst_QQmlPropertyCache: work around name chance in moc-generated code
The offsetsAndSize member was renamed to offsetsAndSize_s_ recently. Detect the name change and use one or the other instead of failing. Fixes: QTBUG-104523 Change-Id: Ica16a91577fd1d20352e2c8136453432acbbc8b0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 5ba6e177904d5ea5f1e44bcc1b1c3ab75d63a065) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp')
-rw-r--r--tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
index 7e1dc2f3e5..14af747024 100644
--- a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
+++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
@@ -572,10 +572,28 @@ class TestClassWithClassInfo : public QObject
#define ARRAY_SIZE(arr) \
int(sizeof(arr) / sizeof(arr[0]))
+template <typename T, typename = void>
+struct SizeofOffsetsAndSizes_helper
+{
+ static constexpr size_t value = sizeof(T::offsetsAndSize); // old moc
+};
+
+template <typename T>
+struct SizeofOffsetsAndSizes_helper<T, std::void_t<decltype(T::offsetsAndSizes)>>
+{
+ static constexpr size_t value = sizeof(T::offsetsAndSizes); // new moc
+};
+
+template <typename T>
+constexpr size_t sizeofOffsetsAndSizes(const T &)
+{
+ return SizeofOffsetsAndSizes_helper<T>::value;
+}
+
#define TEST_CLASS(Class) \
QTest::newRow(#Class) \
<< &Class::staticMetaObject << ARRAY_SIZE(qt_meta_data_##Class) \
- << int(sizeof(qt_meta_stringdata_##Class.offsetsAndSize) / (sizeof(uint) * 2))
+ << int(sizeofOffsetsAndSizes(qt_meta_stringdata_##Class) / (sizeof(uint) * 2))
Q_DECLARE_METATYPE(const QMetaObject*);