diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2017-09-08 12:15:31 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-09-08 10:21:05 +0000 |
commit | 286d72e458c10bae3ce11c58a16352a53ba06aef (patch) | |
tree | e5a7006608a08d8f0d9c7356a51be5318cd4d7dd /src | |
parent | 94641380148e65e126c8533a278f261aaeb87113 (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 struction. Now the context
may live longer and thus the context->contextObject pointer would become
a dangling pointer.
Task-number: QTBUG-63078
Change-Id: I8fdab4086b0472d5d4930cf57aa76922b7ed9e2e
Reviewed-by: Lars Knoll <lars.knoll@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 f31db457d3..13b17e6946 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -716,6 +716,8 @@ void QQmlPrivate::qdeclarativeelement_destructor(QObject *o) for (QQmlContextData *lc = d->ownContext->linkedContext; lc; lc = lc->linkedContext) lc->invalidate(); d->ownContext->invalidate(); + if (d->ownContext->contextObject == o) + d->ownContext->contextObject = nullptr; d->ownContext = 0; d->context = 0; } |