diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-08-18 14:10:12 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-08-23 14:46:22 +0000 |
commit | 7f97d21105f0164c1d3d623d66af56b9f52ae19b (patch) | |
tree | 4a34aa798f33e8dd7d703cc9927029032e7b6575 /tests | |
parent | 469ab6fb956e26771da0cbe2850a72983c206d74 (diff) |
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 <ulf.hermann@qt.io>
(cherry picked from commit e4d62651c278c468f71ce097979bc1183ffd0713)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
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<QProperty<int>> i {new QProperty<int>}; + QPropertyAlias<int> alias(i.get()); + QVERIFY(alias.isValid()); + alias.setValue(42); + QCOMPARE(i->value(), 42); + QProperty<int> 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 |