aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickloader.cpp
diff options
context:
space:
mode:
authorColin Ogilvie <colin.ogilvie@kdab.com>2017-06-02 11:35:07 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2018-07-05 19:59:37 +0000
commitd6a5e14cdd3f233f5df4419c51b1c273b6ea9fe3 (patch)
tree7d043e117139178735a06dfaceee047cd5c91578 /src/quick/items/qquickloader.cpp
parentdf8d59e4b4a486c189263d008d69e4f6c2467d12 (diff)
Don't leak components in QQuickLoader
Only create source component in loadFromSource if it does not already exist. Previously toggling the active status when loading from source would create a new source component every time active became true. [ChangeLog][QtQuick][Loader] Don't leak components when changing source url. Change-Id: I1e4cfd5613e3851fcb4f3f55e78981f7c070cc77 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquickloader.cpp')
-rw-r--r--src/quick/items/qquickloader.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp
index ea6a63559a..b5ae41daef 100644
--- a/src/quick/items/qquickloader.cpp
+++ b/src/quick/items/qquickloader.cpp
@@ -112,6 +112,8 @@ void QQuickLoaderPrivate::clear()
q, SIGNAL(progressChanged()));
component->deleteLater();
component = nullptr;
+ } else if (component) {
+ component = nullptr;
}
componentStrongReference.clear();
source = QUrl();
@@ -438,7 +440,8 @@ void QQuickLoader::loadFromSource()
if (isComponentComplete()) {
QQmlComponent::CompilationMode mode = d->asynchronous ? QQmlComponent::Asynchronous : QQmlComponent::PreferSynchronous;
- d->component = new QQmlComponent(qmlEngine(this), d->source, mode, this);
+ if (!d->component)
+ d->component = new QQmlComponent(qmlEngine(this), d->source, mode, this);
d->load();
}
}
@@ -828,7 +831,8 @@ void QQuickLoader::componentComplete()
if (active()) {
if (d->loadingFromSource) {
QQmlComponent::CompilationMode mode = d->asynchronous ? QQmlComponent::Asynchronous : QQmlComponent::PreferSynchronous;
- d->component = new QQmlComponent(qmlEngine(this), d->source, mode, this);
+ if (!d->component)
+ d->component = new QQmlComponent(qmlEngine(this), d->source, mode, this);
}
d->load();
}