diff options
author | Andy Shaw <andy.shaw@qt.io> | 2017-10-26 11:56:43 +0200 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2017-10-26 11:49:14 +0000 |
commit | 742e869afe2dbba6aae6302d20ba9c82f3ed99c6 (patch) | |
tree | a8dcf6a620fb6f7cd421da51e4808adf7ac212a6 /src | |
parent | 2416b9d6cc2950395151c18a7f7bfceb4b7fc693 (diff) |
Fix crash with dangling context object pointers
This is a regression introduced by commit
e22b624d9ab1f36021adb9cdbfa9b37054282bb8, where the object that owns the
QML context would destroy the context upon destruction. Now the context
may live longer and thus the context->contextObject pointer would become
a dangling pointer.
Task-number: QTBUG-63733
Change-Id: Idc660116752d312917a0a149110b92a042ccfb17
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 5efebe28a2..d99bec4c52 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -891,6 +891,8 @@ void QQmlData::setQueuedForDeletion(QObject *object) if (ddata->ownContext) { Q_ASSERT(ddata->ownContext == ddata->context); ddata->context->emitDestruction(); + if (ddata->ownContext->contextObject == object) + ddata->ownContext->contextObject = nullptr; ddata->ownContext = 0; ddata->context = 0; } |