diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-06-17 12:33:54 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-06-17 19:32:56 +0200 |
commit | 6b36e783521993df8de6477c789aa26c38803656 (patch) | |
tree | 72a0e60c5e65742271c564d1cb4d11d54910daca /tests/auto/corelib | |
parent | 8aee7c6b29be5a0ee7d5e7cfcb5f2db762b2e28b (diff) |
QBindable: Use setter in setValue for QObjectCompatProperty
Directly writing to the underlying property storage has the potential of
breaking all kinds of internal invariants. As we return QBindable in
the public interface, we should not grant callers access to the
internals of the object.
Pick-to: 6.2 6.1
Change-Id: I737ff293b9d921b7de861da5ae23356c17690b78
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp index 60a4e3147d..fb99ed1880 100644 --- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp +++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp @@ -111,6 +111,8 @@ private slots: void uninstalledBindingDoesNotEvaluate(); void notify(); + + void bindableInterfaceOfCompatPropertyUsesSetter(); }; void tst_QProperty::functorBinding() @@ -1836,6 +1838,15 @@ void tst_QProperty::notify() QCOMPARE(recordedValues.at(1), 2); } +void tst_QProperty::bindableInterfaceOfCompatPropertyUsesSetter() +{ + MyQObject obj; + QBindable<int> bindable = obj.bindableCompat(); + QCOMPARE(obj.setCompatCalled, 0); + bindable.setValue(42); + QCOMPARE(obj.setCompatCalled, 1); +} + QTEST_MAIN(tst_QProperty); #undef QT_SOURCE_LOCATION_NAMESPACE |