summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qproperty_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-08-14 09:48:56 +0200
committerLars Knoll <lars.knoll@qt.io>2020-09-02 22:44:27 +0200
commite3ea8768fc3bfed088f70b5d7308e3dd94e93c32 (patch)
treef0d7d1effb8479b5b6e5b47e1dd73108773549e0 /src/corelib/kernel/qproperty_p.h
parente6988d4d0bef2c3f474576250cb305a2f00a688b (diff)
Introduce a common base class for all QProperty types
Add an empty QUntypedPropertyData class. This allows making a couple of places where the system is currently using a void * more type safe. Also add a QPropertyData<T> as an intermediate class between QUntypedPropertyData and QProperty. This class will get used in a future commit to simplify storing property data separately from the possible binding data. Also simplify the static observer handling a bit by always passing it a pointer to the QUntypedPropertyData instead of some other void * that could point to anything. Change-Id: I1f8144ea717815b1bc6f034d1ac883c13af5aaf8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/corelib/kernel/qproperty_p.h')
-rw-r--r--src/corelib/kernel/qproperty_p.h17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h
index 6e8f4b4516..d93db988f9 100644
--- a/src/corelib/kernel/qproperty_p.h
+++ b/src/corelib/kernel/qproperty_p.h
@@ -102,10 +102,10 @@ struct QPropertyObserverPointer
void unlink();
void setBindingToMarkDirty(QPropertyBindingPrivate *binding);
- void setChangeHandler(void (*changeHandler)(QPropertyObserver *, void *));
- void setAliasedProperty(void *propertyPtr);
+ void setChangeHandler(QPropertyObserver::ChangeHandler changeHandler);
+ void setAliasedProperty(QUntypedPropertyData *propertyPtr);
- void notify(QPropertyBindingPrivate *triggeringBinding, void *propertyDataPtr);
+ void notify(QPropertyBindingPrivate *triggeringBinding, QUntypedPropertyData *propertyDataPtr);
void observeProperty(QPropertyBindingDataPointer property);
explicit operator bool() const { return ptr != nullptr; }
@@ -147,14 +147,13 @@ private:
union {
ObserverArray inlineDependencyObservers;
struct {
- void *staticObserver;
QtPrivate::QPropertyObserverCallback staticObserverCallback;
QtPrivate::QPropertyGuardFunction staticGuardCallback;
};
};
QScopedPointer<std::vector<QPropertyObserver>> heapObservers;
- void *propertyDataPtr = nullptr;
+ QUntypedPropertyData *propertyDataPtr = nullptr;
QPropertyBindingSourceLocation location;
QPropertyBindingError error;
@@ -175,11 +174,10 @@ public:
virtual ~QPropertyBindingPrivate();
void setDirty(bool d) { dirty = d; }
- void setProperty(void *propertyPtr) { propertyDataPtr = propertyPtr; }
- void setStaticObserver(void *observer, QtPrivate::QPropertyObserverCallback callback,
- QtPrivate::QPropertyGuardFunction guardCallback)
+ void setProperty(QUntypedPropertyData *propertyPtr) { propertyDataPtr = propertyPtr; }
+ void setStaticObserver(QtPrivate::QPropertyObserverCallback callback, QtPrivate::QPropertyGuardFunction guardCallback)
{
- if (observer) {
+ if (callback) {
if (!hasStaticObserver) {
if (dependencyObserverCount > 0) {
if (!heapObservers)
@@ -191,7 +189,6 @@ public:
}
hasStaticObserver = true;
- staticObserver = observer;
staticObserverCallback = callback;
staticGuardCallback = guardCallback;
} else if (hasStaticObserver) {