From 47fb07c9fdf47584ae55f3412102bbeef5576b04 Mon Sep 17 00:00:00 2001 From: mae Date: Wed, 17 Mar 2010 17:13:00 +0100 Subject: Improve implicit "." import The change moves the implicit "." import to the very end, i.e. the first lookup. It also gets the content of a remote qmldir from the resources. --- .../qml/qdeclarativecompositetypemanager.cpp | 37 ++++++++++++---------- src/declarative/qml/qdeclarativeengine.cpp | 7 ++++ 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp index 5f80000..5014323 100644 --- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp +++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp @@ -511,22 +511,6 @@ 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; @@ -568,6 +552,27 @@ int QDeclarativeCompositeTypeManager::resolveTypes(QDeclarativeCompositeTypeData } } + /* + For local urls, add an implicit import "." as first lookup. This will also trigger + the loading of the qmldir and the import of any native types from available plugins. + */ + { + + QString qmldircontentnetwork; + if (QDeclarativeCompositeTypeResource *resource + = resources.value(unit->imports.baseUrl().resolved(QUrl(QLatin1String("./qmldir"))))) + qmldircontentnetwork = QString::fromUtf8(resource->data); + + QDeclarativeEnginePrivate::get(engine)-> + addToImport(&unit->imports, + qmldircontentnetwork, + QLatin1String("."), + QString(), + -1, -1, + QDeclarativeScriptParser::Import::File); + } + + QList types = unit->data.referencedTypes(); for (int ii = 0; ii < types.count(); ++ii) { diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 4449404..ce4a9f1 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1587,6 +1587,8 @@ public: } url = base.resolved(QUrl(url)).toString(); + if (url.endsWith(QLatin1Char('/'))) + url.chop(1); } s->uris.prepend(uri); @@ -1623,6 +1625,11 @@ public: } } + + + /* now comes really nasty code. It makes "private" types load in the remote case, but + it does this by breaking the import order. This must go. Instead private types must + be marked private in the qmldir. */ if (url_return) { *url_return = base.resolved(QUrl(QString::fromUtf8(type + ".qml"))); return true; -- cgit v0.12