diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-06-17 12:33:54 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-06-17 19:13:08 +0000 |
commit | 6900bd8a3672cca6f50252bfe59ddaeeae033243 (patch) | |
tree | 9d8e491f8bc3f31cd6a769cb5f08176be253bf9b /tests | |
parent | 4d4e13c68474ac7b1a64d64d5bada58bbe8b47ba (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.
Change-Id: I737ff293b9d921b7de861da5ae23356c17690b78
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
(cherry picked from commit 6b36e783521993df8de6477c789aa26c38803656)
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 | 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 735d45da2a..9f14778159 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 |