summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorPo-Hao Su <supohaosu@gmail.com>2023-11-09 20:32:55 +0800
committerPo-Hao Su <supohaosu@gmail.com>2023-12-09 08:37:44 +0800
commit311f8896322bcd39d33369c8311a8c89ccdad449 (patch)
tree116a2a1592e5a4a5644b8d6d5c5d7c94343ca384 /src/corelib/kernel
parentead408ca1b0b689bea269543117d89316ab23d0b (diff)
QProperty: clean up unnecessary sentinel class
Instead of introducing the nested class InheritsQUntypedPropertyData as a sentinel class for inheritance check, we can use BinaryTypeTrait to handle the check. By doing this, we no longer need to maintain the nested class. Change-Id: Ie3aae976015d5fae6b6d072cad6ee52cd30b769d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qproperty.h12
-rw-r--r--src/corelib/kernel/qpropertyprivate.h7
2 files changed, 14 insertions, 5 deletions
diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h
index 32d7a44506..54df12fbfe 100644
--- a/src/corelib/kernel/qproperty.h
+++ b/src/corelib/kernel/qproperty.h
@@ -263,7 +263,8 @@ public:
QPropertyObserver &operator=(QPropertyObserver &&other) noexcept;
~QPropertyObserver();
- template<typename Property, typename = typename Property::InheritsQUntypedPropertyData>
+ template <typename Property,
+ typename = std::enable_if_t<std::is_base_of_v<QUntypedPropertyData, Property>>>
void setSource(const Property &property)
{ setSource(property.bindingData()); }
void setSource(const QtPrivate::QPropertyBindingData &property);
@@ -302,7 +303,8 @@ public:
{
}
- template<typename Property, typename = typename Property::InheritsQUntypedPropertyData>
+ template <typename Property,
+ typename = std::enable_if_t<std::is_base_of_v<QUntypedPropertyData, Property>>>
Q_NODISCARD_CTOR
QPropertyChangeHandler(const Property &property, Functor handler)
: QPropertyObserver([](QPropertyObserver *self, QUntypedPropertyData *) {
@@ -332,7 +334,8 @@ public:
{
}
- template<typename Functor, typename Property, typename = typename Property::InheritsQUntypedPropertyData>
+ template <typename Functor, typename Property,
+ typename = std::enable_if_t<std::is_base_of_v<QUntypedPropertyData, Property>>>
Q_NODISCARD_CTOR
QPropertyNotifier(const Property &property, Functor handler)
: QPropertyObserver([](QPropertyObserver *self, QUntypedPropertyData *) {
@@ -906,7 +909,8 @@ public:
iface->setObserver(aliasedProperty(), this);
}
- template<typename Property, typename = typename Property::InheritsQUntypedPropertyData>
+ template <typename Property,
+ typename = std::enable_if_t<std::is_base_of_v<QUntypedPropertyData, Property>>>
QPropertyAlias(Property *property)
: QPropertyObserver(property),
iface(&QtPrivate::QBindableInterfaceForProperty<Property>::iface)
diff --git a/src/corelib/kernel/qpropertyprivate.h b/src/corelib/kernel/qpropertyprivate.h
index aca6d14c96..fa8fe04d5d 100644
--- a/src/corelib/kernel/qpropertyprivate.h
+++ b/src/corelib/kernel/qpropertyprivate.h
@@ -125,8 +125,13 @@ struct QPropertyObserverPointer;
class QUntypedPropertyData
{
public:
+#if QT_DEPRECATED_SINCE(6, 8)
// sentinel to check whether a class inherits QUntypedPropertyData
- struct InheritsQUntypedPropertyData {};
+ struct QT_DEPRECATED_VERSION_X_6_8("Use std::is_base_of instead.")
+ InheritsQUntypedPropertyData
+ {
+ };
+#endif
};
template <typename T>