summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-02-12 15:35:36 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2021-02-15 20:38:58 +0100
commit4d579851c842e136fbaf7a5d629c249456a91e39 (patch)
tree500cb0a96cf4a19d74988a5974997fe04aac87ea
parentf61b140482d9578c07410a5979379e44e05352e5 (diff)
QPropertyBindingPrivate: Add further support code for QML
This adds a public function to check whether the QPropertyBindingPrivate is a normal binding, or a QQmlPropertyBinding. In addition, this check is used so that the source location function doesn't return garbage, but instead indicates that the binding was set up from QML. A function to retrieve the binding location from C++ can be added to declarative at a later point. Change-Id: Ica0f70780735fe9c60d01c2b21057d59714079e0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
-rw-r--r--src/corelib/kernel/qproperty_p.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h
index 1e6dab4c64..fe15b91438 100644
--- a/src/corelib/kernel/qproperty_p.h
+++ b/src/corelib/kernel/qproperty_p.h
@@ -298,7 +298,15 @@ public:
return {&heapObservers->emplace_back()};
}
- QPropertyBindingSourceLocation sourceLocation() const { return location; }
+ QPropertyBindingSourceLocation sourceLocation() const
+ {
+ if (!hasCustomVTable())
+ return this->location;
+ QPropertyBindingSourceLocation location;
+ constexpr auto msg = "Custom location";
+ location.fileName = msg;
+ return location;
+ }
QPropertyBindingError bindingError() const { return error; }
QMetaType valueMetaType() const { return metaType; }
@@ -330,8 +338,13 @@ public:
static QPropertyBindingPrivate *currentlyEvaluatingBinding();
+ bool hasCustomVTable() const
+ {
+ return vtable->size == 0;
+ }
+
static void destroyAndFreeMemory(QPropertyBindingPrivate *priv) {
- if (priv->vtable->size == 0) {
+ if (priv->hasCustomVTable()) {
// special hack for QQmlPropertyBinding which has a
// different memory layout than normal QPropertyBindings
priv->vtable->destroy(priv);