From 2eb2d6386da304cd1164264ae0bff685c796d89c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 23 Oct 2017 20:45:00 -0500 Subject: Prevent errors when unloading Loader Invalidate the context of the object so that destruction is signaled and bindings no longer run. Task-number: QTBUG-47321 Task-number: QTBUG-51995 Task-number: QTBUG-60344 Change-Id: I194a2fefe4e769a58c9ce022d39fe76cbe230de7 Reviewed-by: Michael Brasser --- src/quick/items/qquickloader.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/quick/items/qquickloader.cpp') diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp index 27afe5a5db..27b8d32707 100644 --- a/src/quick/items/qquickloader.cpp +++ b/src/quick/items/qquickloader.cpp @@ -96,6 +96,12 @@ void QQuickLoaderPrivate::clear() delete itemContext; itemContext = 0; + // Prevent any bindings from running while waiting for deletion. Without + // this we may get transient errors from use of 'parent', for example. + QQmlContext *context = qmlContext(object); + if (context) + QQmlContextData::get(context)->invalidate(); + if (loadingFromSource && component) { // disconnect since we deleteLater QObject::disconnect(component, SIGNAL(statusChanged(QQmlComponent::Status)), @@ -351,6 +357,12 @@ void QQuickLoader::setActive(bool newVal) d->itemContext = 0; } + // Prevent any bindings from running while waiting for deletion. Without + // this we may get transient errors from use of 'parent', for example. + QQmlContext *context = qmlContext(d->object); + if (context) + QQmlContextData::get(context)->invalidate(); + if (d->item) { QQuickItemPrivate *p = QQuickItemPrivate::get(d->item); p->removeItemChangeListener(d, watchedChanges); -- cgit v1.2.3