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>bb10
parent
f61b140482
commit
4d579851c8
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue