From 6b36e783521993df8de6477c789aa26c38803656 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Thu, 17 Jun 2021 12:33:54 +0200 Subject: 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 Reviewed-by: Andreas Buhr --- tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/auto/corelib') 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 bindable = obj.bindableCompat(); + QCOMPARE(obj.setCompatCalled, 0); + bindable.setValue(42); + QCOMPARE(obj.setCompatCalled, 1); +} + QTEST_MAIN(tst_QProperty); #undef QT_SOURCE_LOCATION_NAMESPACE -- cgit v1.2.3