diff options
author | Alexander Volkov <a.volkov@rusbitech.ru> | 2017-06-13 13:40:10 +0300 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-06-13 14:00:46 +0000 |
commit | 7c27955968bab135b0e0db3a5f707efa86e80464 (patch) | |
tree | ff5e50cc2dad5b2f7da3beb447877f8670b1b238 /src/qml/qml/qqmlfile.cpp | |
parent | 84275fda5eaf709043572d6bbd76d5714c517af7 (diff) |
Fix loading QML caches for qrc:/// urls
Running examples/quick/window/window produces debug messages:
"QML source file has moved to a different location."
This is because QQmlFile::urlToLocalFileOrQrc(const QString &) overload
is incompatible with QQmlFile::urlToLocalFileOrQrc(const QUrl &) when it
deals with qrc:/// urls. For example it returns ":///window/window.qml"
while the QUrl overload returns ":/window/window.qml". Thus the comparison
of source paths in CompilationUnit::loadFromDisk() fails.
Fix the incompatibility and add a test.
Change-Id: I20449b8cf13d715d88860f2cd413ab39c893f3ef
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlfile.cpp')
-rw-r--r-- | src/qml/qml/qqmlfile.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlfile.cpp b/src/qml/qml/qqmlfile.cpp index 4e4db086b0..93c3e8e00c 100644 --- a/src/qml/qml/qqmlfile.cpp +++ b/src/qml/qml/qqmlfile.cpp @@ -603,6 +603,12 @@ empty string. */ QString QQmlFile::urlToLocalFileOrQrc(const QString& url) { + if (url.startsWith(QLatin1String("qrc://"), Qt::CaseInsensitive)) { + if (url.length() > 6) + return QLatin1Char(':') + url.midRef(6); + return QString(); + } + if (url.startsWith(QLatin1String("qrc:"), Qt::CaseInsensitive)) { if (url.length() > 4) return QLatin1Char(':') + url.midRef(4); |