aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qml
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-01-02 14:04:48 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2017-01-03 09:53:31 +0000
commit9b2b06fd7bf07e1012b47798f38ba881e693436f (patch)
tree4a0993cd1870d724447e199f604675996973a252 /tools/qml
parentf70066e95e7e23562155686cb7d7874b2d5da5a1 (diff)
qml: use QUrl::fromUserInput("file.qml", QDir::currentPath())
After change dc6b73390b262b9554599cbf40539763b1280261 in qtbase, the qml runtime was failing at an assertion in QQmlTypeLoader::getType() which tries to avoid relative URLs and relative directory paths. It's important to convert relative paths to fully-qualified paths when converting to an URL, because QQmlTypeLoader uses it as a cache key, and we want to avoid ambiguity about which file is being cached. Task-number: QTBUG-57870 Change-Id: Ib984cf722009f5f04cb67fffbc52d12bcc98df89 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'tools/qml')
-rw-r--r--tools/qml/main.cpp30
1 files changed, 7 insertions, 23 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index 5e8b872821..e8a506264c 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -46,7 +46,6 @@
#include <QDir>
#include <QFile>
#include <QFileInfo>
-#include <QRegularExpression>
#include <QStringList>
#include <QScopedPointer>
#include <QDebug>
@@ -568,29 +567,14 @@ int main(int argc, char *argv[])
loadDummyDataFiles(e, dummyDir);
for (const QString &path : qAsConst(files)) {
- //QUrl::fromUserInput doesn't treat no scheme as relative file paths
-#if QT_CONFIG(regularexpression)
- QRegularExpression urlRe("[[:word:]]+://.*");
- if (urlRe.match(path).hasMatch()) { //Treat as a URL
- QUrl url = QUrl::fromUserInput(path);
- if (verboseMode)
- printf("qml: loading %s\n",
- qPrintable(url.isLocalFile()
- ? QDir::toNativeSeparators(url.toLocalFile())
- : url.toString()));
+ QUrl url = QUrl::fromUserInput(path, QDir::currentPath());
+ if (verboseMode)
+ printf("qml: loading %s\n", qPrintable(url.toString()));
+ QByteArray strippedFile;
+ if (getFileSansBangLine(path, strippedFile))
+ e.loadData(strippedFile, e.baseUrl().resolved(url)); //QQmlComponent won't resolve it for us, it doesn't know it's a valid file if we loadData
+ else //Errors or no bang line
e.load(url);
- } else
-#endif
- { //Local file path
- if (verboseMode)
- printf("qml: loading %s\n", qPrintable(QDir::toNativeSeparators(path)));
-
- QByteArray strippedFile;
- if (getFileSansBangLine(path, strippedFile))
- e.loadData(strippedFile, e.baseUrl().resolved(QUrl::fromLocalFile(path))); //QQmlComponent won't resolve it for us, it doesn't know it's a valid file if we loadData
- else //Errors or no bang line
- e.load(path);
- }
}
if (lw->earlyExit)