diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-03-21 10:48:38 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-03-21 20:41:23 +0100 |
commit | 908ee8aab1d9b5d022cadb23d23de56ca72570e9 (patch) | |
tree | 43f87cb461bb7703a464d2654a68dddd079fe338 /tests/auto/corelib/kernel | |
parent | cbf8fc0ac43365f4dd69c64ec770d8f547d772f3 (diff) |
QProperty: Allow manual scheduling of binding notification
In some situation we want to notify even if the value didn't change.
Task-number: QTBUG-101771
Pick-to: 6.2 6.3
Change-Id: I7d82a9f6e0f7d5eb48065e3f428b814939181ea8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/corelib/kernel')
-rw-r--r-- | tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp index 877896407a..0f89ccee8b 100644 --- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp +++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp @@ -118,6 +118,7 @@ private slots: void selfBindingShouldNotCrash(); void qpropertyAlias(); + void scheduleNotify(); }; void tst_QProperty::functorBinding() @@ -2015,6 +2016,21 @@ void tst_QProperty::qpropertyAlias() QVERIFY(!alias.isValid()); } +void tst_QProperty::scheduleNotify() +{ + int notifications = 0; + QProperty<int> p; + QCOMPARE(p.value(), 0); + const auto handler = p.addNotifier([&](){ ++notifications; }); + QCOMPARE(notifications, 0); + QPropertyBinding<int> b([]() { return 0; }, QPropertyBindingSourceLocation()); + QPropertyBindingPrivate::get(b)->scheduleNotify(); + QCOMPARE(notifications, 0); + p.setBinding(b); + QCOMPARE(notifications, 1); + QCOMPARE(p.value(), 0); +} + QTEST_MAIN(tst_QProperty); #undef QT_SOURCE_LOCATION_NAMESPACE |