From 6778b247a8c20adfb3f4e3094077baae43f3e65c Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 25 Aug 2020 12:27:09 +0200 Subject: Add a QBindingStorage class QBindingStorage is a class that can store a set of binding objects for the properties of a QObject. This will get used to reduce the memory overhead of the property system when adding bindable properties to QObject based classes. The binding storage has a pointer to the TLS entry containing the currently evaluating binding. Like that we avoid repeated TLS lookups and reduce the overhead of the property system to one pointer lookup and one compare for the case that properties aren't being used. Each QObject now owns one binding storage object, that can be used to store binding data for properties that members of the QObject. Change-Id: I27427c03c2ba281f072e074be96147bdbcaac246 Reviewed-by: Fabian Kosmale --- src/corelib/kernel/qobject.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/corelib/kernel/qobject.cpp') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 4d0523c898..5bb225d396 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1532,6 +1532,10 @@ void QObject::moveToThread(QThread *targetThread) qWarning("QObject::moveToThread: Widgets cannot be moved to a new thread"); return; } + if (!d->bindingStorage.isEmpty()) { + qWarning("QObject::moveToThread: Can not move objects that contain bindings or are used in bindings to a new thread."); + return; + } QThreadData *currentData = QThreadData::current(); QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr; @@ -4046,6 +4050,24 @@ QList QObject::dynamicPropertyNames() const return QList(); } +/*! + \internal +*/ +QBindingStorage *QObject::bindingStorage() +{ + Q_D(QObject); + return &d->bindingStorage; +} + +/*! + \internal +*/ +const QBindingStorage *QObject::bindingStorage() const +{ + Q_D(const QObject); + return &d->bindingStorage; +} + #endif // QT_NO_PROPERTIES -- cgit v1.2.3