diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2018-11-29 11:28:49 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2018-11-30 09:09:36 +0000 |
commit | b17091b0006e41c0bb4ddf77dbbc09621d809aea (patch) | |
tree | fd27f9b48ee209b13d545fa8df46d147b0566d24 /src | |
parent | d0a52c72b5756787ceb6094117cd71d935badc06 (diff) |
QML: Also clear outerContext's contextObject on destruction
A QObject can not only be set as contextObject of the own context, but
also as contextObject of the outerContext of a respective QQmlData. This
can be seen in QQmlObjectCreator::createInstance(...) if isContextObject
is true.
Therefore, when catching a QObject deletion we need to clear the pointer
in the outerContext if that refers to the object being deleted.
Fixes: QTBUG-71037
Change-Id: Ib6ba99bd5336f7582486b2128515021245370c60
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index f288646ec7..c400e9239b 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -755,6 +755,9 @@ void QQmlPrivate::qdeclarativeelement_destructor(QObject *o) d->context = nullptr; } + if (d->outerContext && d->outerContext->contextObject == o) + d->outerContext->contextObject = nullptr; + // Mark this object as in the process of deletion to // prevent it resolving in bindings QQmlData::markAsDeleted(o); |