From 7c27955968bab135b0e0db3a5f707efa86e80464 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Tue, 13 Jun 2017 13:40:10 +0300 Subject: 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 --- src/qml/qml/qqmlfile.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') 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); -- cgit v1.2.3