summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2020-12-04 09:11:50 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-12-04 13:08:26 +0000
commit87409ce0007e92d43f8e502f44528858c84b85d4 (patch)
tree2b0140b1d2dbb74e4e88b5e7fe229dcb46c05caa /src/corelib/kernel
parent3f94498303cec8f18509ff273254b80a7fe355e7 (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 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qproperty.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h
index 946014dc6d..a533f424e8 100644
--- a/src/corelib/kernel/qproperty.h
+++ b/src/corelib/kernel/qproperty.h
@@ -630,7 +630,7 @@ public:
QPropertyBinding<T> setBinding(const QPropertyBinding<T> &binding)
{
Q_ASSERT(!iface || binding.isNull() || binding.valueMetaType() == iface->metaType());
- return iface ? static_cast<QPropertyBinding<T> &&>(iface->setBinding(data, binding)) : QPropertyBinding<T>();
+ return (iface && iface->setBinding) ? static_cast<QPropertyBinding<T> &&>(iface->setBinding(data, binding)) : QPropertyBinding<T>();
}
#ifndef Q_CLANG_QDOC
template <typename Functor>
@@ -657,7 +657,7 @@ public:
void setValue(const T &value)
{
- if (iface)
+ if (iface && iface->setter)
iface->setter(data, &value);
}
};