aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlimport.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-06-10 12:36:31 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-06-10 17:48:01 +0200
commitd52a10eccd6fd7fae7481330e816975ba2b64f91 (patch)
treeede89aedbec213671f45b9563efb4992dda37546 /src/qml/qml/qqmlimport.cpp
parent31ee1bc904e4fc565f7198b47fcf7305e4f4d5d7 (diff)
QQmlImport: Parse resource paths from QML2_IMPORT_PATH
We can interpret double colons as start of resource paths. Task-number: QTBUG-69435 Change-Id: If2b4412c28c7c59f160ddfcfe04ec293af437660 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlimport.cpp')
-rw-r--r--src/qml/qml/qqmlimport.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index a6a230090e..b1d304924d 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -1893,12 +1893,28 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e)
// env import paths
if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QML2_IMPORT_PATH"))) {
const QString envImportPath = qEnvironmentVariable("QML2_IMPORT_PATH");
-#if defined(Q_OS_WIN)
- QLatin1Char pathSep(';');
-#else
- QLatin1Char pathSep(':');
-#endif
- QStringList paths = envImportPath.split(pathSep, Qt::SkipEmptyParts);
+ const QChar pathSep = QDir::listSeparator();
+ QStringList paths;
+ if (pathSep == u':') {
+ // Double colons are interpreted as separator + resource path.
+ paths = envImportPath.split(u':');
+ bool wasEmpty = false;
+ for (auto it = paths.begin(); it != paths.end();) {
+ if (it->isEmpty()) {
+ wasEmpty = true;
+ it = paths.erase(it);
+ } else {
+ if (wasEmpty) {
+ it->prepend(u':');
+ wasEmpty = false;
+ }
+ ++it;
+ }
+ }
+ } else {
+ paths = envImportPath.split(pathSep, Qt::SkipEmptyParts);
+ }
+
for (int ii = paths.count() - 1; ii >= 0; --ii)
addImportPath(paths.at(ii));
}