summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/qml/qdeclarativecompositetypemanager.cpp31
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp1
2 files changed, 28 insertions, 4 deletions
diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
index e2a6e0c..5f80000 100644
--- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp
+++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
@@ -315,12 +315,17 @@ void QDeclarativeCompositeTypeManager::resourceReplyFinished()
reply->deleteLater();
}
+// XXX this beyonds in QUrl::toLocalFile()
+// WARNING, there is a copy of this function in qdeclarativeengine.cpp
static QString toLocalFileOrQrc(const QUrl& url)
{
- QString r = url.toLocalFile();
- if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
- r = QLatin1Char(':') + url.path();
- return r;
+ if (url.scheme() == QLatin1String("qrc")) {
+ if (url.authority().isEmpty())
+ return QLatin1Char(':') + url.path();
+ qWarning() << "Invalid url:" << url.toString() << "authority" << url.authority() << "not known.";
+ return QString();
+ }
+ return url.toLocalFile();
}
void QDeclarativeCompositeTypeManager::loadResource(QDeclarativeCompositeTypeResource *resource)
@@ -505,6 +510,24 @@ int QDeclarativeCompositeTypeManager::resolveTypes(QDeclarativeCompositeTypeData
int waiting = 0;
+
+ /*
+ For local urls, add an implicit import "." to the beginning of a file. This will trigger
+ the loading of the qmldir and the import of any native types from available plugins.
+ */
+ QUrl baseUrl = unit->imports.baseUrl();
+ if (!toLocalFileOrQrc(baseUrl).isEmpty()) {
+ QDeclarativeEnginePrivate::get(engine)->
+ addToImport(&unit->imports,
+ QString(),
+ QLatin1String("."),
+ QString(),
+ -1, -1,
+ QDeclarativeScriptParser::Import::File);
+
+ }
+
+
foreach (QDeclarativeScriptParser::Import imp, unit->data.imports()) {
QString qmldircontentnetwork;
if (imp.type == QDeclarativeScriptParser::Import::File && imp.qualifier.isEmpty()) {
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 7c21ab8..f4eeff4 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -1342,6 +1342,7 @@ QVariant QDeclarativeScriptClass::toVariant(QDeclarativeEngine *engine, const QS
}
// XXX this beyonds in QUrl::toLocalFile()
+// WARNING, there is a copy of this function in qdeclarativecompositetypemanager.cpp
static QString toLocalFileOrQrc(const QUrl& url)
{
if (url.scheme() == QLatin1String("qrc")) {