aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorAlan Alpert <aalpert@blackberry.com>2013-07-18 06:02:37 -0700
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-11 12:18:15 +0100
commit054e50babc340f1d8b6c037fca143f90dbd0c1f2 (patch)
treed15e6d1a746d28138bdf479024a51c94cb5fa8a2 /src/qml/qml
parent98c47db70a72a8afbd86afd355dadb1ce9113361 (diff)
Intercept qmldir files with the url interceptor
There's another code path which loads qmldir files directly, and it did not use the interceptor when available. Note that this, like other interceptors, does not affect baseUrl and so any other qmldir file still must have paths relative from the initial URL. Change-Id: I620943c36d488d22fbaf1793514075d31ab76e3e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmltypeloader.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 4b398fb6b8..85d2fe41d9 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -1801,9 +1801,25 @@ bool QQmlTypeLoader::directoryExists(const QString &path)
Return a QmldirContent for absoluteFilePath. The QmldirContent may be cached.
\a filePath is either a bundle URL, or a local file path.
+
+It can also be a remote path for a remote directory import, but it will have been cached by now in this case.
*/
-const QQmlTypeLoader::QmldirContent *QQmlTypeLoader::qmldirContent(const QString &filePath, const QString &uriHint)
-{
+const QQmlTypeLoader::QmldirContent *QQmlTypeLoader::qmldirContent(const QString &filePathIn, const QString &uriHint)
+{
+ QUrl url(filePathIn); //May already contain bundle or http scheme
+ if (url.scheme() == QLatin1String("http") || url.scheme() == QLatin1String("https"))
+ return *(m_importQmlDirCache.value(filePathIn)); //Can't load the remote here, but should be cached
+ else if (!QQmlFile::isBundle(filePathIn))
+ url = QUrl::fromLocalFile(filePathIn);
+ if (engine() && engine()->urlInterceptor())
+ url = engine()->urlInterceptor()->intercept(url, QQmlAbstractUrlInterceptor::QmldirFile);
+ Q_ASSERT(url.scheme() == QLatin1String("file") || url.scheme() == QLatin1String("bundle"));
+ QString filePath;
+ if (url.scheme() == QLatin1String("file"))
+ filePath = url.toLocalFile();
+ else
+ filePath = url.path();
+
QmldirContent *qmldir;
QmldirContent **val = m_importQmlDirCache.value(filePath);
if (!val) {
@@ -1813,13 +1829,10 @@ const QQmlTypeLoader::QmldirContent *QQmlTypeLoader::qmldirContent(const QString
#define NOT_READABLE_ERROR QString(QLatin1String("module \"$$URI$$\" definition \"%1\" not readable"))
#define CASE_MISMATCH_ERROR QString(QLatin1String("cannot load module \"$$URI$$\": File name case mismatch for \"%1\""))
- if (QQmlFile::isBundle(filePath)) {
-
- QUrl url(filePath);
-
+ if (QQmlFile::isBundle(url.toString())) {
QQmlFile file(engine(), url);
if (file.isError()) {
- ERROR(NOT_READABLE_ERROR.arg(filePath));
+ ERROR(NOT_READABLE_ERROR.arg(url.toString()));
} else {
QString content(QString::fromUtf8(file.data(), file.size()));
qmldir->setContent(filePath, content);