aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickloader.cpp
diff options
context:
space:
mode:
authorWang Chuan <ouchuanm@outlook.com>2020-08-15 15:26:51 +0800
committerWang Chuan <ouchuanm@outlook.com>2020-08-22 17:02:38 +0000
commit3d195d33ece3f8fd7cd7d8e6163fe038fc7fc036 (patch)
treef2947bb1ef53e99d3d56167e5a33f23b3e87b34c /src/quick/items/qquickloader.cpp
parentb953bd67d4134b9af3e554a0287a462ddf2de5f7 (diff)
QQuickLoader: make sure the status property change properly
When we call [setSource] in qml, we will try to convert a qml value to a string which indicate the url we want to load. However, if this value is undefined, it will convert to a string with content "undefined", and then cause loading error. More worse, if there is a qml file named "undefined", it will be loaded to the Loader. Pick-to: 5.15 Fixes: QTBUG-85938 Change-Id: I5b192ba84aa29532e547349bbf37d413c107d8e4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/quick/items/qquickloader.cpp')
-rw-r--r--src/quick/items/qquickloader.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp
index f1e70c14f4..d5a822c26f 100644
--- a/src/quick/items/qquickloader.cpp
+++ b/src/quick/items/qquickloader.cpp
@@ -963,6 +963,8 @@ QUrl QQuickLoaderPrivate::resolveSourceUrl(QQmlV4Function *args)
{
QV4::Scope scope(args->v4engine());
QV4::ScopedValue v(scope, (*args)[0]);
+ if (v->isUndefined())
+ return QUrl();
QString arg = v->toQString();
return arg.isEmpty() ? QUrl() : scope.engine->callingQmlContext()->resolvedUrl(QUrl(arg));
}