aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2020-06-11 08:15:19 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2020-06-15 10:41:37 +0200
commitca6fc80570644af271f8c846d696317d12f1a0fb (patch)
tree3abb816acf3fe8c8623bc7f8768df0616d0865c4
parent90bf30376c94b2fcf99e2d8382b40e8881be47be (diff)
Fix QQmlPropertyBinding::evaluate
When a class is in a semi-deleted state (QQmlData::wasDeletet returns true, but the QQmlElement has not been removed yet), we can still end up calling evaluate under some circumstance. This can be observed in qqc2's tests, for instance tst_palette. In those cases either ctxt or ctxt->engine() might be nullptr. We handle this by returning an error; as the object is about to be gone, the result does not matter anyway. Change-Id: I8a42263a9b44012822f5a827da8eae97d3160165 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--src/qml/qml/qqmlpropertybinding.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/qml/qml/qqmlpropertybinding.cpp b/src/qml/qml/qqmlpropertybinding.cpp
index c7f620c88c..c8442cf510 100644
--- a/src/qml/qml/qqmlpropertybinding.cpp
+++ b/src/qml/qml/qqmlpropertybinding.cpp
@@ -85,7 +85,12 @@ QQmlPropertyBinding::QQmlPropertyBinding(const QMetaType &mt)
QUntypedPropertyBinding::BindingEvaluationResult QQmlPropertyBinding::evaluate(const QMetaType &metaType, void *dataPtr)
{
- QQmlEngine *engine = context()->engine();
+ const auto ctxt = context();
+ QQmlEngine *engine = ctxt ? ctxt->engine() : nullptr;
+ if (!engine) {
+ QPropertyBindingError error(QPropertyBindingError::EvaluationError);
+ return error;
+ }
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
ep->referenceScarceResources();