diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-12-04 09:11:50 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-12-04 13:08:26 +0000 |
commit | 87409ce0007e92d43f8e502f44528858c84b85d4 (patch) | |
tree | 2b0140b1d2dbb74e4e88b5e7fe229dcb46c05caa /tests/auto/corelib | |
parent | 3f94498303cec8f18509ff273254b80a7fe355e7 (diff) |
QBindable: Disallow mutation if read-only
If a QBindable is created from a computed property, it is not possible
to actually set a value or a binding. If we try to do it anyway, we'd
get a crash. Thus we now check whether the function pointer is null
before invoking it.
Task-number: QTBUG-87153
Change-Id: I5bedb9080ccf79d9b8166b80d5733d095ed76f8d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit e236faa75f446aa3378fb013cce6598c9e076ccb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp index 8145b066da..3cc7bd6f9c 100644 --- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp +++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp @@ -1114,6 +1114,11 @@ void tst_QProperty::testNewStuff() object.readData.setValue(111); QCOMPARE(object.computed(), 111); + object.bindableComputed().setBinding(object.bindableBar().makeBinding()); + QCOMPARE(object.computed(), 111); + object.bindableComputed().setValue(10); + QCOMPARE(object.computed(), 111); + QCOMPARE(object.bindableFoo().value(), 111); object.bindableFoo().setValue(24); QCOMPARE(object.foo(), 24); |