diff options
author | Wang Chuan <ouchuanm@outlook.com> | 2020-08-15 14:57:06 +0800 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-08-25 03:24:48 +0000 |
commit | d535b85a84ee89530a80b606701910a90681bdce (patch) | |
tree | b8ff528f076364ee5cdcace1a2dc70791b9852ed /src/quick/items/qquickloader.cpp | |
parent | 9ca1ebf9d1d5b8c34ac1148740567b77d629b85e (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.
Fixes: QTBUG-85938
Change-Id: If61a33c790a4fd6562611c4c50756bc5e213363a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 3aa4cd682f52b70803cc3f72d732bde9987677dd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/quick/items/qquickloader.cpp')
-rw-r--r-- | src/quick/items/qquickloader.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp index e1d533f092..e961617505 100644 --- a/src/quick/items/qquickloader.cpp +++ b/src/quick/items/qquickloader.cpp @@ -589,8 +589,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); |