summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qpropertyprivate.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/qpropertyprivate.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/qpropertyprivate.h')
-rw-r--r--src/corelib/kernel/qpropertyprivate.h25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/corelib/kernel/qpropertyprivate.h b/src/corelib/kernel/qpropertyprivate.h
index bab4162472..33ecb405f2 100644
--- a/src/corelib/kernel/qpropertyprivate.h
+++ b/src/corelib/kernel/qpropertyprivate.h
@@ -65,14 +65,21 @@ class QPropertyBindingPrivate;
using QPropertyBindingPrivatePtr = QExplicitlySharedDataPointer<QPropertyBindingPrivate>;
struct QPropertyBindingDataPointer;
+class QUntypedPropertyData
+{
+public:
+ // sentinel to check whether a class inherits QUntypedPropertyData
+ struct InheritsQUntypedPropertyData {};
+};
+
namespace QtPrivate {
// writes binding result into dataPtr
-using QPropertyBindingFunction = std::function<bool(QMetaType metaType, void *dataPtr)>;
+using QPropertyBindingFunction = std::function<bool(QMetaType metaType, QUntypedPropertyData *dataPtr)>;
-using QPropertyGuardFunction = bool(*)(QMetaType, void *dataPtr,
- QPropertyBindingFunction, void *owner);
-using QPropertyObserverCallback = void (*)(void *, void *);
+using QPropertyGuardFunction = bool(*)(QMetaType, QUntypedPropertyData *dataPtr,
+ QPropertyBindingFunction);
+using QPropertyObserverCallback = void (*)(QUntypedPropertyData *);
class Q_CORE_EXPORT QPropertyBindingData
{
@@ -84,16 +91,16 @@ public:
QPropertyBindingData() = default;
Q_DISABLE_COPY(QPropertyBindingData)
QPropertyBindingData(QPropertyBindingData &&other) = delete;
- QPropertyBindingData(QPropertyBindingData &&other, void *propertyDataPtr);
+ QPropertyBindingData(QPropertyBindingData &&other, QUntypedPropertyData *propertyDataPtr);
QPropertyBindingData &operator=(QPropertyBindingData &&other) = delete;
~QPropertyBindingData();
- void moveAssign(QPropertyBindingData &&other, void *propertyDataPtr);
+ void moveAssign(QPropertyBindingData &&other, QUntypedPropertyData *propertyDataPtr);
bool hasBinding() const { return d_ptr & BindingBit; }
QUntypedPropertyBinding setBinding(const QUntypedPropertyBinding &newBinding,
- void *propertyDataPtr, void *staticObserver = nullptr,
+ QUntypedPropertyData *propertyDataPtr,
QPropertyObserverCallback staticObserverCallback = nullptr,
QPropertyGuardFunction guardCallback = nullptr);
QPropertyBindingPrivate *binding() const;
@@ -102,7 +109,7 @@ public:
void removeBinding();
void registerWithCurrentlyEvaluatingBinding() const;
- void notifyObservers(void *propertyDataPtr) const;
+ void notifyObservers(QUntypedPropertyData *propertyDataPtr) const;
void setExtraBit(bool b)
{
@@ -182,7 +189,7 @@ struct QPropertyGuardFunctionHelper
template<typename T, typename Class, auto Guard>
struct QPropertyGuardFunctionHelper<T, Class, Guard, false>
{
- static auto guard(const QMetaType metaType, void *dataPtr,
+ static auto guard(QMetaType metaType, QUntypedPropertyData *dataPtr,
QPropertyBindingFunction eval, void *owner) -> bool
{
T t = T();