From 286d72e458c10bae3ce11c58a16352a53ba06aef Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 8 Sep 2017 12:15:31 +0200 Subject: 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 --- src/qml/qml/qqmlengine.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/qml') 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; } -- cgit v1.2.3