From 9b22095657b8b1c3fb01f529a3ae2e663eb86ab9 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 23 Jun 2022 08:56:42 +0200 Subject: 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 (cherry picked from commit 5ba6e177904d5ea5f1e44bcc1b1c3ab75d63a065) Reviewed-by: Qt Cherry-pick Bot --- .../qml/qqmlpropertycache/tst_qqmlpropertycache.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'tests/auto') 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 +struct SizeofOffsetsAndSizes_helper +{ + static constexpr size_t value = sizeof(T::offsetsAndSize); // old moc +}; + +template +struct SizeofOffsetsAndSizes_helper> +{ + static constexpr size_t value = sizeof(T::offsetsAndSizes); // new moc +}; + +template +constexpr size_t sizeofOffsetsAndSizes(const T &) +{ + return SizeofOffsetsAndSizes_helper::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*); -- cgit v1.2.3