From 787dbda672d6df4ff2336bb3afda62a233b88aaa Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 25 Oct 2017 14:50:14 +0200 Subject: Check linked contexts for context objects being deleted In QQmlObjectCreator::createInstance we can assign the new object as context object to a linkedContext of its QQmlData, not only it's ownContext. Consequently, we have to check all the linked contexts and remove the object when found on deletion. Change-Id: I09bccdb0190406245fa5a379edaff0a8f118062f Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlengine.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 612c3439c1..5350ad38a3 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -714,8 +714,11 @@ void QQmlPrivate::qdeclarativeelement_destructor(QObject *o) { if (QQmlData *d = QQmlData::get(o)) { if (d->ownContext) { - for (QQmlContextData *lc = d->ownContext->linkedContext; lc; lc = lc->linkedContext) + for (QQmlContextData *lc = d->ownContext->linkedContext; lc; lc = lc->linkedContext) { lc->invalidate(); + if (lc->contextObject == o) + lc->contextObject = nullptr; + } d->ownContext->invalidate(); if (d->ownContext->contextObject == o) d->ownContext->contextObject = nullptr; -- cgit v1.2.3