diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index f54cd732789..4a8874caf4b 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -641,11 +641,13 @@ QPropertyObserver::QPropertyObserver(ChangeHandler changeHandler) d.setChangeHandler(changeHandler); } +#if QT_DEPRECATED_SINCE(6, 6) QPropertyObserver::QPropertyObserver(QUntypedPropertyData *data) { aliasData = data; next.setTag(ObserverIsAlias); } +#endif /*! \internal */ diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h index 297a3fe9740..5d8b908f31a 100644 --- a/src/corelib/kernel/qproperty.h +++ b/src/corelib/kernel/qproperty.h @@ -217,7 +217,9 @@ public: ObserverNotifiesBinding, // observer was installed to notify bindings that obsverved property changed ObserverNotifiesChangeHandler, // observer is a change handler, which runs on every change ObserverIsPlaceholder, // the observer before this one is currently evaluated in QPropertyObserver::notifyObservers. +#if QT_DEPRECATED_SINCE(6, 6) ObserverIsAlias +#endif }; protected: using ChangeHandler = void (*)(QPropertyObserver*, QUntypedPropertyData *); @@ -257,7 +259,9 @@ public: protected: QPropertyObserver(ChangeHandler changeHandler); - QPropertyObserver(QUntypedPropertyData *aliasedPropertyPtr); +#if QT_DEPRECATED_SINCE(6, 6) + QT_DEPRECATED QPropertyObserver(QUntypedPropertyData *aliasedPropertyPtr); +#endif QUntypedPropertyData *aliasedProperty() const { @@ -867,13 +871,16 @@ public: } }; +#if QT_DEPRECATED_SINCE(6, 6) template -class QPropertyAlias : public QPropertyObserver +class QT_DEPRECATED_X("Class was only meant for internal use, use a QProperty and add a binding to the target") +QPropertyAlias : public QPropertyObserver { Q_DISABLE_COPY_MOVE(QPropertyAlias) const QtPrivate::QBindableInterface *iface = nullptr; public: + QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED QPropertyAlias(QProperty *property) : QPropertyObserver(property), iface(&QtPrivate::QBindableInterfaceForProperty>::iface) @@ -989,7 +996,9 @@ public: { return aliasedProperty() != nullptr; } + QT_WARNING_POP }; +#endif template class QObjectBindableProperty : public QPropertyData diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h index 42daca036a7..3ae1bfcc23b 100644 --- a/src/corelib/kernel/qproperty_p.h +++ b/src/corelib/kernel/qproperty_p.h @@ -124,13 +124,17 @@ struct QPropertyObserverPointer void unlink() { unlink_common(); +#if QT_DEPRECATED_SINCE(6, 6) if (ptr->next.tag() == QPropertyObserver::ObserverIsAlias) ptr->aliasData = nullptr; +#endif } void unlink_fast() { +#if QT_DEPRECATED_SINCE(6, 6) Q_ASSERT(ptr->next.tag() != QPropertyObserver::ObserverIsAlias); +#endif unlink_common(); } @@ -881,8 +885,10 @@ inline void QPropertyObserverPointer::notify(QUntypedPropertyData *propertyDataP case QPropertyObserver::ObserverIsPlaceholder: // recursion is already properly handled somewhere else break; +#if QT_DEPRECATED_SINCE(6, 6) case QPropertyObserver::ObserverIsAlias: break; +#endif default: Q_UNREACHABLE(); } observer = next; diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp index 335cc65b5ab..dbdcaa1a1b2 100644 --- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp +++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp @@ -2240,6 +2240,8 @@ void tst_QProperty::selfBindingShouldNotCrash() void tst_QProperty::qpropertyAlias() { +#if QT_DEPRECATED_SINCE(6, 6) + QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED std::unique_ptr> i {new QProperty}; QPropertyAlias alias(i.get()); QVERIFY(alias.isValid()); @@ -2251,6 +2253,8 @@ void tst_QProperty::qpropertyAlias() QCOMPARE(alias.value(), 42); i.reset(); QVERIFY(!alias.isValid()); + QT_WARNING_POP +#endif } void tst_QProperty::scheduleNotify()