QProperty: Cleanup QPropertyAlias leftovers

This removes traces of QPropertyAlias which is internal API which is
a) not really working even before this change (no compatibility with
   QBindableInterface due to QPropertyAlias not being derived from
   QUntypedPropertyData)
b) not used anywhere

For BIC reasons, we need to keep some methods still around until Qt 7,
though.

Change-Id: I5bb4735a4c88cba275dc2cc6e29a46ca09622059
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Fabian Kosmale 2021-05-11 10:52:34 +02:00
parent 6d87f9a526
commit 524c187af3
4 changed files with 4 additions and 105 deletions

View File

@ -571,10 +571,9 @@ QPropertyObserver::QPropertyObserver(ChangeHandler changeHandler)
d.setChangeHandler(changeHandler);
}
QPropertyObserver::QPropertyObserver(QUntypedPropertyData *aliasedPropertyPtr)
QPropertyObserver::QPropertyObserver(QUntypedPropertyData *)
{
QPropertyObserverPointer d{this};
d.setAliasedProperty(aliasedPropertyPtr);
// ### Qt 7: Remove, currently left for binary compatibility
}
/*! \internal
@ -625,8 +624,6 @@ QPropertyObserver &QPropertyObserver::operator=(QPropertyObserver &&other) noexc
void QPropertyObserverPointer::unlink()
{
if (ptr->next.tag() == QPropertyObserver::ObserverNotifiesAlias)
ptr->aliasedPropertyData = nullptr;
if (ptr->next)
ptr->next->prev = ptr->prev;
if (ptr->prev)
@ -642,13 +639,6 @@ void QPropertyObserverPointer::setChangeHandler(QPropertyObserver::ChangeHandler
ptr->next.setTag(QPropertyObserver::ObserverNotifiesChangeHandler);
}
void QPropertyObserverPointer::setAliasedProperty(QUntypedPropertyData *property)
{
Q_ASSERT(ptr->next.tag() != QPropertyObserver::ObserverIsPlaceholder);
ptr->aliasedPropertyData = property;
ptr->next.setTag(QPropertyObserver::ObserverNotifiesAlias);
}
void QPropertyObserverPointer::setBindingToNotify(QPropertyBindingPrivate *binding)
{
Q_ASSERT(ptr->next.tag() != QPropertyObserver::ObserverIsPlaceholder);
@ -708,9 +698,6 @@ void QPropertyObserverPointer::notify(QUntypedPropertyData *propertyDataPtr)
*/
while (observer) {
QPropertyObserver *next = observer->next.data();
char preventBug[1] = {'\0'}; // QTBUG-87245
Q_UNUSED(preventBug);
switch (QPropertyObserver::ObserverTag(observer->next.tag())) {
case QPropertyObserver::ObserverNotifiesChangeHandler:
{
@ -734,11 +721,10 @@ void QPropertyObserverPointer::notify(QUntypedPropertyData *propertyDataPtr)
next = protector.next();
break;
}
case QPropertyObserver::ObserverNotifiesAlias:
break;
case QPropertyObserver::ObserverIsPlaceholder:
// recursion is already properly handled somewhere else
break;
default: Q_UNREACHABLE();
}
observer = next;
}

View File

@ -215,7 +215,6 @@ public:
enum ObserverTag {
ObserverNotifiesBinding, // observer was installed to notify bindings that obsverved property changed
ObserverNotifiesChangeHandler, // observer is a change handler, which runs on every change
ObserverNotifiesAlias, // used for QPropertyAlias
ObserverIsPlaceholder // the observer before this one is currently evaluated in QPropertyObserver::notifyObservers.
};
protected:
@ -237,7 +236,6 @@ private:
union {
QPropertyBindingPrivate *binding = nullptr;
ChangeHandler changeHandler;
QUntypedPropertyData *aliasedPropertyData;
};
};
@ -260,7 +258,7 @@ protected:
QUntypedPropertyData *aliasedProperty() const
{
return aliasedPropertyData;
return nullptr;
}
private:

View File

@ -105,7 +105,6 @@ struct QPropertyObserverPointer
void setBindingToNotify(QPropertyBindingPrivate *binding);
void setChangeHandler(QPropertyObserver::ChangeHandler changeHandler);
void setAliasedProperty(QUntypedPropertyData *propertyPtr);
void notify(QUntypedPropertyData *propertyDataPtr);
#ifndef QT_NO_DEBUG

View File

@ -83,7 +83,6 @@ private slots:
void genericPropertyBindingBool();
void setBindingFunctor();
void multipleObservers();
void propertyAlias();
void arrowAndStarOperator();
void notifiedProperty();
void typeNoOperatorEqual();
@ -97,7 +96,6 @@ private slots:
void qobjectObservers();
void compatBindings();
void metaProperty();
void aliasOnMetaProperty();
void modifyObserverListWhileIterating();
void compatPropertyNoDobuleNotification();
@ -791,52 +789,6 @@ void tst_QProperty::multipleObservers()
QCOMPARE(property.value(), 22);
}
void tst_QProperty::propertyAlias()
{
QScopedPointer<QProperty<int>> property(new QProperty<int>);
property->setValue(5);
QPropertyAlias alias(property.get());
QVERIFY(alias.isValid());
QCOMPARE(alias.value(), 5);
int value1 = 1;
auto changeHandler = alias.onValueChanged([&]() { value1 = alias.value(); });
QCOMPARE(value1, 1);
int value2 = 2;
auto subscribeHandler = alias.subscribe([&]() { value2 = alias.value(); });
QCOMPARE(value2, 5);
alias.setValue(6);
QVERIFY(alias.isValid());
QCOMPARE(alias.value(), 6);
QCOMPARE(value1, 6);
QCOMPARE(value2, 6);
alias.setBinding([]() { return 12; });
QCOMPARE(value1, 12);
QCOMPARE(value2, 12);
QCOMPARE(alias.value(), 12);
alias.setValue(22);
QCOMPARE(value1, 22);
QCOMPARE(value2, 22);
QCOMPARE(alias.value(), 22);
property.reset();
QVERIFY(!alias.isValid());
QCOMPARE(alias.value(), int());
QCOMPARE(value1, 22);
QCOMPARE(value2, 22);
// Does not crash
alias.setValue(25);
QCOMPARE(alias.value(), int());
QCOMPARE(value1, 22);
QCOMPARE(value2, 22);
}
void tst_QProperty::arrowAndStarOperator()
{
QString str("Hello");
@ -1445,42 +1397,6 @@ void tst_QProperty::metaProperty()
QCOMPARE(object.fooData.value(), 1);
}
void tst_QProperty::aliasOnMetaProperty()
{
MyQObject object;
QPropertyAlias<int> alias(object.bindableFoo());
QVERIFY(alias.isValid());
QCOMPARE(alias.value(), object.foo());
QVERIFY(!alias.hasBinding());
object.setFoo(42);
QCOMPARE(alias.value(), 42);
auto f = [&object]() -> int {
return object.barData;
};
object.bindableFoo().setBinding(f);
QVERIFY(alias.hasBinding());
QCOMPARE(alias.value(), object.bar());
object.setBar(111);
QCOMPARE(alias.value(), 111);
int changedCount = 0;
auto observer = alias.onValueChanged([&changedCount]() { ++changedCount; });
QCOMPARE(changedCount, 0);
object.setBar(666);
QCOMPARE(changedCount, 1);
alias.setBinding([&object]() { return object.read(); });
QCOMPARE(changedCount, 2);
QCOMPARE(alias.value(), 0);
object.readData = 100;
QCOMPARE(changedCount, 3);
QCOMPARE(alias.value(), 100);
}
void tst_QProperty::modifyObserverListWhileIterating()
{
struct DestructingObserver : QPropertyObserver {