diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2017-10-25 14:50:14 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2017-11-28 09:42:30 +0000 |
commit | 787dbda672d6df4ff2336bb3afda62a233b88aaa (patch) | |
tree | 3773d3586a997f2245597d4a9d346c10e864dc75 | |
parent | 323fd0037c8d3e016c66fea024b57b11763624ed (diff) |
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 <simon.hausmann@qt.io>
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
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; |