aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlpropertybinding_p.h
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-07-05 11:14:55 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2021-07-06 08:38:26 +0200
commit4df72982059f529f9391e9d25923e88e6aa619f7 (patch)
treed67a7fcbc56fdabb0b817b5c95653bc9831adddb /src/qml/qml/qqmlpropertybinding_p.h
parent3059864c323777f542d5da0eba71c56d78559dab (diff)
Fix binding functor addressing in QQmlPropertyBinding
This mirrors the change in qtbase. Task-number: QTBUG-93890 Pick-to: 6.1 6.2 Change-Id: I761b320e4dd4b1e2884bb9c0e01b28cc15c4ac2d Reviewed-by: Jaeyoon Jung <jaeyoon.jung@lge.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlpropertybinding_p.h')
-rw-r--r--src/qml/qml/qqmlpropertybinding_p.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlpropertybinding_p.h b/src/qml/qml/qqmlpropertybinding_p.h
index 2765a13a21..341e300de4 100644
--- a/src/qml/qml/qqmlpropertybinding_p.h
+++ b/src/qml/qml/qqmlpropertybinding_p.h
@@ -109,7 +109,7 @@ public:
{
return std::launder(reinterpret_cast<QQmlPropertyBindingJS const *>(
reinterpret_cast<std::byte const*>(this)
- + sizeof(QQmlPropertyBinding)
+ + QPropertyBindingPrivate::getSizeEnsuringAlignment()
+ jsExpressionOffsetLength()));
}
@@ -146,7 +146,7 @@ public:
static bool doEvaluate(QMetaType metaType, QUntypedPropertyData *dataPtr, void *f) {
auto address = static_cast<std::byte*>(f);
- address -= sizeof (QPropertyBindingPrivate); // f now points to QPropertyBindingPrivate suboject
+ address -= QPropertyBindingPrivate::getSizeEnsuringAlignment(); // f now points to QPropertyBindingPrivate suboject
// and that has the same address as QQmlPropertyBinding
return reinterpret_cast<QQmlPropertyBinding *>(address)->evaluate(metaType, dataPtr);
}
@@ -237,10 +237,12 @@ inline const QQmlPropertyBinding *QQmlPropertyBindingJS::asBinding() const
{
return std::launder(reinterpret_cast<QQmlPropertyBinding const *>(
reinterpret_cast<std::byte const*>(this)
- - sizeof(QQmlPropertyBinding)
+ - QPropertyBindingPrivate::getSizeEnsuringAlignment()
- QQmlPropertyBinding::jsExpressionOffsetLength()));
}
+static_assert(sizeof(QQmlPropertyBinding) == sizeof(QPropertyBindingPrivate)); // else the whole offset computatation will break
+
QT_END_NAMESPACE
#endif // QQMLPROPERTYBINDING_P_H