aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2021-03-02 07:54:09 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-03-09 15:38:05 +0000
commitce9386db8f34b78b295d9f0d975df0a7822274f7 (patch)
treeabf4f59db874418ebb4ee2c6d0c9260cc5ea99e1
parent6b6acc328ef599ea6ddcd18e1240fcaf777cb4b8 (diff)
Ensure that the case of the path will match then QUrl for a UNC path
When a UNC path is used to locate the qmldir then when it is checked later on the original path will be compared against the one that QUrl returns. However, QUrl will convert the case of the host name to be all lower-case whereas the original string may have been in upper-case. For example, QUrl::fromLocalFile("//QT-L-R90X9VHB/tasks").toString() will output "file://qt-l-r90x9vhb/tasks". So in this case, the absoluteFilePath is changed at this point so that it will match what QUrl has for the same path to avoid a problem with it no being found. Change-Id: I2cd5d74bfec06c01635f80574ac1a6d479792855 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit e0400d08755bb40c303bbe330bc3bd6045436c22) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/qml/qml/qqmlimport.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index a6a8c54845..6592bfa6c6 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -1420,11 +1420,16 @@ QQmlImports::LocalQmldirResult QQmlImportsPrivate::locateLocalQmldir(
if (!absoluteFilePath.isEmpty()) {
QString url;
const QStringView absolutePath = QStringView{absoluteFilePath}.left(absoluteFilePath.lastIndexOf(Slash) + 1);
- if (absolutePath.at(0) == Colon)
+ if (absolutePath.at(0) == Colon) {
url = QLatin1String("qrc") + absolutePath;
- else
+ } else {
url = QUrl::fromLocalFile(absolutePath.toString()).toString();
-
+ // This handles the UNC path case as when the path is retrieved from the QUrl it
+ // will convert the host name from upper case to lower case. So the absoluteFilePath
+ // is changed at this point to make sure it will match later on in that case.
+ if (absoluteFilePath.startsWith(QLatin1String("//")))
+ absoluteFilePath = QUrl::fromLocalFile(absoluteFilePath).toString(QUrl::RemoveScheme);
+ }
QQmlImportDatabase::QmldirCache *cache = new QQmlImportDatabase::QmldirCache;
cache->version = version;
cache->qmldirFilePath = absoluteFilePath;