diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2020-04-30 08:34:42 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-06-25 14:11:56 +0200 |
commit | b20c7df63aec36cb3cb871e4b898b0e684dcb59a (patch) | |
tree | 9c2e2dc72ef823d4e92f3ed2cf043ac68d03baf5 /src/corelib/kernel/qproperty.h | |
parent | e18a060c034beec6c7f4a22044255d9fb55d091a (diff) |
Remove QPropertyMemberChangeHandler again
Adding support for a static notifier within QProperty itself - through a
QProperty "sister" class - is more efficient in terms of memory
consumption and run-time performance.
The MemberChangeHandler permanently takes up at least three pointers,
while the notified properties only cost one pointer in the binding.
Change-Id: Ia1a8c2b66f1f3c2fe13ae0ad9f12cdb6bdcc35ef
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/corelib/kernel/qproperty.h')
-rw-r--r-- | src/corelib/kernel/qproperty.h | 23 |
1 files changed, 0 insertions, 23 deletions
diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h index 5ba4d2eda7..de08a71349 100644 --- a/src/corelib/kernel/qproperty.h +++ b/src/corelib/kernel/qproperty.h @@ -731,28 +731,6 @@ QPropertyChangeHandler<Functor> QNotifiedProperty<T, Callback, ValueGuard>::subs return onValueChanged(f); } -template <auto propertyMember, auto callbackMember> -struct QPropertyMemberChangeHandler; - -template<typename Class, typename PropertyType, PropertyType Class::* PropertyMember, void(Class::*Callback)()> -struct QPropertyMemberChangeHandler<PropertyMember, Callback> : public QPropertyObserver -{ - QPropertyMemberChangeHandler(Class *obj) - : QPropertyObserver(notify) - { - setSource(obj->*PropertyMember); - } - - static void notify(QPropertyObserver *, void *propertyDataPtr) - { - // memberOffset is the offset of the QProperty<> member within the class. We get the absolute address - // of that member and subtracting the relative offset gives us the address of the class instance. - const size_t memberOffset = reinterpret_cast<size_t>(&(static_cast<Class *>(nullptr)->*PropertyMember)); - Class *obj = reinterpret_cast<Class *>(reinterpret_cast<char *>(propertyDataPtr) - memberOffset); - (obj->*Callback)(); - } -}; - template<typename T> class QPropertyAlias : public QPropertyObserver { @@ -892,7 +870,6 @@ public: return aliasedProperty<T>() != nullptr; } }; - QT_END_NAMESPACE #endif // QPROPERTY_H |