From 7f97d21105f0164c1d3d623d66af56b9f52ae19b Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Wed, 18 Aug 2021 14:10:12 +0200 Subject: Re-add QPropertyAlias functionality As QPropertyAlias was public by accident in 6.0, we have to ensure that it still works in 6.2. This re-adds some tests for it, and reimplements the unlinking functionality. To avoid performance regressions in hot-paths, a new unlink_fast function is added, which behaves like the old unlink: It ignores the special handling for QPropertyAlias, so that we can skip the tag check. It is only used in QPropertyObserverNodeProtector and clearDependencyObservers, where we already know the type of the observer. Fixes: QTBUG-95846 Change-Id: Ifb405b8327c4d61c673b1a912ed6e169d27c2d8f Reviewed-by: Ulf Hermann (cherry picked from commit e4d62651c278c468f71ce097979bc1183ffd0713) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp index 214512f20d..3cfdcfc7b0 100644 --- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp +++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp @@ -115,6 +115,8 @@ private slots: void bindableInterfaceOfCompatPropertyUsesSetter(); void selfBindingShouldNotCrash(); + + void qpropertyAlias(); }; void tst_QProperty::functorBinding() @@ -1856,6 +1858,21 @@ void tst_QProperty::selfBindingShouldNotCrash() QVERIFY(i.binding().error().hasError()); } +void tst_QProperty::qpropertyAlias() +{ + std::unique_ptr> i {new QProperty}; + QPropertyAlias alias(i.get()); + QVERIFY(alias.isValid()); + alias.setValue(42); + QCOMPARE(i->value(), 42); + QProperty j; + i->setBinding([&]() -> int { return j; }); + j.setValue(42); + QCOMPARE(alias.value(), 42); + i.reset(); + QVERIFY(!alias.isValid()); +} + QTEST_MAIN(tst_QProperty); #undef QT_SOURCE_LOCATION_NAMESPACE -- cgit v1.2.3