diff options
author | Michael Brasser <michael.brasser@live.com> | 2017-10-23 20:45:00 -0500 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2018-01-05 07:06:43 +0000 |
commit | 2eb2d6386da304cd1164264ae0bff685c796d89c (patch) | |
tree | 4eec8683182ebe462864c9c92bb7aebf782ad000 /src/quick/items/qquickloader.cpp | |
parent | f6fbf988ef8802010a79ad7456b922f5ff3ee63e (diff) |
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 <michael.brasser@live.com>
Diffstat (limited to 'src/quick/items/qquickloader.cpp')
-rw-r--r-- | src/quick/items/qquickloader.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
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); |