From 73842034aac7b9788add4f1ba6cf7a9ec6057598 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Mon, 23 Jul 2012 10:59:30 +1000 Subject: Fix QML import paths in Qt resources. Allow adding qrc: urls as import paths. Store an import path of the form :/import/path as qrc:/import/path which is expected by other parts of the code. Update documentation for QQmlEngine::addImportPath() to explicitly state what types of paths are supported. Add auto tests to check that importing a module from a Qt resource works. Change-Id: If0e75c75078a608b20d7a5c4080bccf6241e97f6 Reviewed-by: Chris Adams --- src/qml/qml/qqmlimport.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/qml/qml/qqmlimport.cpp') diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 55c07ac35a..20da154673 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -1536,6 +1536,11 @@ void QQmlImportDatabase::addImportPath(const QString& path) if (url.scheme() == QLatin1String("file")) { cPath = QQmlFile::urlToLocalFileOrQrc(url); + } else if (path.startsWith(QLatin1Char(':'))) { + // qrc directory, e.g. :/foo + // need to convert to a qrc url, e.g. qrc:/foo + cPath = QStringLiteral("qrc") + path; + cPath.replace(Backslash, Slash); } else if (url.isRelative() || (url.scheme().length() == 1 && QFile::exists(path)) ) { // windows path QDir dir = QDir(path); -- cgit v1.2.3