aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlimport.cpp
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2021-03-02 07:54:09 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-03-09 12:18:31 +0000
commite0400d08755bb40c303bbe330bc3bd6045436c22 (patch)
tree040dd3f90202da5d2fda7d40a70d7ae8d1149e81 /src/qml/qml/qqmlimport.cpp
parent602982993cb73584d9bfae91f0073384bc1e6850 (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. Pick-to: 6.1 6.0 5.15 Change-Id: I2cd5d74bfec06c01635f80574ac1a6d479792855 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlimport.cpp')
-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 0016d4bcc4..1d2d0d15cd 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -1436,11 +1436,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;