QPropertyBindingPrivate: Support QQmlProperyBinding

QQmlProperyBinding needs the ability to suspend binding evaluation, and
needs access to the propertyDataPtr.

Change-Id: If82079ffdf28fb277c6e5083714c28478f6e1729
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
bb10
Fabian Kosmale 2021-02-06 22:22:56 +01:00
parent 4d579851c8
commit 99db1d54ed
3 changed files with 10 additions and 2 deletions

View File

@ -1697,6 +1697,7 @@ QPropertyBindingData *QBindingStorage::bindingData_helper(QUntypedPropertyData *
}
namespace QtPrivate {
BindingEvaluationState *suspendCurrentBindingStatus()
{
auto ret = bindingStatus.currentlyEvaluatingBinding;
@ -1709,7 +1710,6 @@ void restoreBindingStatus(BindingEvaluationState *status)
bindingStatus.currentlyEvaluatingBinding = status;
}
namespace QtPrivate {
/*!
\internal
This function can be used to detect whether we are currently

View File

@ -193,6 +193,7 @@ private:
QPropertyObserverPointer firstObserver; // list of observers observing us
QScopedPointer<std::vector<QPropertyObserver>> heapObservers; // for things we are observing
protected:
QUntypedPropertyData *propertyDataPtr = nullptr;
/* For bindings set up from C++, location stores where the binding was created in the C++ source
@ -203,7 +204,6 @@ private:
*/
static_assert(std::is_trivially_destructible_v<QPropertyBindingSourceLocation>);
static_assert(std::is_trivially_destructible_v<std::byte[sizeof(QPropertyBindingSourceLocation)]>);
protected:
using DeclarativeErrorCallback = void(*)(QPropertyBindingPrivate *);
union {
QPropertyBindingSourceLocation location;
@ -353,6 +353,7 @@ public:
delete[] reinterpret_cast<std::byte *>(priv);
}
}
private:
bool evaluateIfDirtyAndReturnTrueIfValueChanged_helper(const QUntypedPropertyData *data, QBindingStatus *status = nullptr);
};
@ -584,6 +585,11 @@ private:
QObjectCompatProperty<Class, Type, Class::_qt_property_##name##_offset, setter>( \
value);
namespace QtPrivate {
Q_CORE_EXPORT BindingEvaluationState *suspendCurrentBindingStatus();
Q_CORE_EXPORT void restoreBindingStatus(BindingEvaluationState *status);
}
QT_END_NAMESPACE
#endif // QPROPERTY_P_H

View File

@ -69,6 +69,7 @@ struct RefCounted {
};
}
class QQmlPropertyBinding;
class QPropertyBindingPrivate;
class QPropertyBindingPrivatePtr
{
@ -223,6 +224,7 @@ class Q_CORE_EXPORT QPropertyBindingData
// notification later when the value changes.
mutable quintptr d_ptr = 0;
friend struct QT_PREPEND_NAMESPACE(QPropertyBindingDataPointer);
friend class QT_PREPEND_NAMESPACE(QQmlPropertyBinding);
Q_DISABLE_COPY(QPropertyBindingData)
public:
QPropertyBindingData() = default;