aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickloader.cpp
diff options
context:
space:
mode:
authorWang Chuan <ouchuanm@outlook.com>2020-08-15 14:57:06 +0800
committerWang Chuan <ouchuanm@outlook.com>2020-08-22 15:59:12 +0000
commit3aa4cd682f52b70803cc3f72d732bde9987677dd (patch)
tree528594dd07ad45b26594256c2a018988a852b2c9 /src/quick/items/qquickloader.cpp
parenta29eb1c15200363a175c1b3a9ad2189b63b9765f (diff)
QQuickLoader: make sure the status property change properly
Since the invocation of [setSource] in qml will clear the old source url first, it is hard to decide whether we have changed the source url, especially when we call [setSource] with an empty string, and the loader's status won't change properly. Pick-to: 5.15 Fixes: QTBUG-85938 Change-Id: If61a33c790a4fd6562611c4c50756bc5e213363a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/quick/items/qquickloader.cpp')
-rw-r--r--src/quick/items/qquickloader.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp
index 0d47931063..f1e70c14f4 100644
--- a/src/quick/items/qquickloader.cpp
+++ b/src/quick/items/qquickloader.cpp
@@ -588,8 +588,15 @@ void QQuickLoader::setSource(QQmlV4Function *args)
if (ipvError)
return;
+ // 1. If setSource is called with a valid url, clear the old component and its corresponding url
+ // 2. If setSource is called with an invalid url(e.g. empty url), clear the old component but
+ // hold the url for old one.(we will compare it with new url later and may update status of loader to Loader.Null)
+ QUrl oldUrl = d->source;
d->clear();
QUrl sourceUrl = d->resolveSourceUrl(args);
+ if (!sourceUrl.isValid())
+ d->source = oldUrl;
+
d->disposeInitialPropertyValues();
if (!ipv->isUndefined()) {
d->initialPropertyValues.set(args->v4engine(), ipv);