Deprecate QPropertyAlias
That use case for the class never materialized, and it was actually meant for internal use. However, we put it into the public header, so we cannot remove it (and while undocumented, someone actually used it at some point, compare e4d62651c278c468f71ce097979bc1183ffd0713). Mark it as deprecated instead so that it can be finally be removed in Qt 7. Change-Id: I058c5831a44610121fbec6eaddebd8b33d4a16c9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
parent
1dc5e20c16
commit
f69bcf8d80
@ -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
|
||||
*/
|
||||
|
@ -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<typename T>
|
||||
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<T> *property)
|
||||
: QPropertyObserver(property),
|
||||
iface(&QtPrivate::QBindableInterfaceForProperty<QProperty<T>>::iface)
|
||||
@ -989,7 +996,9 @@ public:
|
||||
{
|
||||
return aliasedProperty() != nullptr;
|
||||
}
|
||||
QT_WARNING_POP
|
||||
};
|
||||
#endif
|
||||
|
||||
template<typename Class, typename T, auto Offset, auto Signal = nullptr>
|
||||
class QObjectBindableProperty : public QPropertyData<T>
|
||||
|
@ -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;
|
||||
|
@ -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<QProperty<int>> i {new QProperty<int>};
|
||||
QPropertyAlias<int> 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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user