summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qproperty.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2020-02-27 14:11:51 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2020-03-19 13:09:13 +0100
commit4a702e580eec2d6efc4f80664725bd90bfcaa4e0 (patch)
tree2c67ac949d55238d4260002f543f5aa349742435 /src/corelib/kernel/qproperty.h
parent58992993a381fedd2f0e36edb73a63cfb9b3bcea (diff)
Use QTaggedPointer in QPropertyObserver
This replaces the private tagged pointer and the use of enums for the tag makes the observer handling code more readable. The pointer-to-tagged-pointer class remains in qpropertyprivate.h due to its exoticness. Change-Id: Icc88799136c6839426d994b42368526463265e66 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qproperty.h')
-rw-r--r--src/corelib/kernel/qproperty.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h
index 5e1d8ec2f6..21b2ed0839 100644
--- a/src/corelib/kernel/qproperty.h
+++ b/src/corelib/kernel/qproperty.h
@@ -387,6 +387,13 @@ struct QPropertyObserverPointer;
struct Q_CORE_EXPORT QPropertyObserver
{
+ // Internal
+ enum ObserverTag {
+ ObserverNotifiesBinding = 0x0,
+ ObserverNotifiesChangeHandler = 0x1,
+ };
+ Q_DECLARE_FLAGS(ObserverTags, ObserverTag)
+
QPropertyObserver() = default;
QPropertyObserver(QPropertyObserver &&other);
QPropertyObserver &operator=(QPropertyObserver &&other);
@@ -402,10 +409,10 @@ protected:
private:
void setSource(QtPrivate::QPropertyBase &property);
- QtPrivate::QTaggedPointer<QPropertyObserver> next;
+ QTaggedPointer<QPropertyObserver, ObserverTags> next;
// prev is a pointer to the "next" element within the previous node, or to the "firstObserverPtr" if it is the
// first node.
- QtPrivate::QPropertyTagPreservingPointerToPointer<QPropertyObserver> prev;
+ QtPrivate::QTagPreservingPointerToPointer<QPropertyObserver, ObserverTags> prev;
union {
QPropertyBindingPrivate *bindingToMarkDirty = nullptr;
@@ -416,8 +423,11 @@ private:
QPropertyObserver &operator=(const QPropertyObserver &) = delete;
friend struct QPropertyObserverPointer;
+ friend struct QPropertyBasePointer;
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QPropertyObserver::ObserverTags)
+
template <typename Functor>
class QPropertyChangeHandler : public QPropertyObserver
{