summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-04-01 03:51:18 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-04-01 03:51:18 (GMT)
commit4d523c7cb2d3322c3b4512148b9d34ca5fe34225 (patch)
tree729e7869aae82e6ce560d42b152593f1dcdb53c9
parentf78c58d59c1d772aa1a332fc8e90991d242ad273 (diff)
parente890d1d289a299d8e9734b4d96b58fc9c5e0768d (diff)
downloadQt-4d523c7cb2d3322c3b4512148b9d34ca5fe34225.zip
Qt-4d523c7cb2d3322c3b4512148b9d34ca5fe34225.tar.gz
Qt-4d523c7cb2d3322c3b4512148b9d34ca5fe34225.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
-rw-r--r--doc/src/declarative/modules.qdoc6
-rw-r--r--src/declarative/qml/qdeclarativecompositetypemanager.cpp50
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/LocalLast.qml2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/LocalLast.qml2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp7
6 files changed, 41 insertions, 27 deletions
diff --git a/doc/src/declarative/modules.qdoc b/doc/src/declarative/modules.qdoc
index 6b2e64e..d476d6f 100644
--- a/doc/src/declarative/modules.qdoc
+++ b/doc/src/declarative/modules.qdoc
@@ -169,8 +169,10 @@ import Ovi 1.0 as Nokia
While import statements are needed to make any types available in QML, the directory of the
current file is implicitly loaded. This is the exact same as if you had added 'import "."' to
-every QML file. The effect of this is that you can automatically use types defined in C++ plugins
-or QML files if they reside in the same directory.
+the start of every QML file. The effect of this is that you can automatically use types defined in C++ plugins
+or QML files if they reside in the same directory. This is the last location searched for types - so if you
+happen to have a "Text.qml" file, or "text.qml" on case-insensitive file systems, it will not override
+the one from Qt if you import Qt.
*/
diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
index c59e5e2..eb8c9eb 100644
--- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp
+++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
@@ -537,6 +537,31 @@ int QDeclarativeCompositeTypeManager::resolveTypes(QDeclarativeCompositeTypeData
int waiting = 0;
+ /*
+ For local urls, add an implicit import "." as first (most overridden) lookup. This will also trigger
+ the loading of the qmldir and the import of any native types from available plugins.
+ */
+ {
+
+ QDeclarativeDirComponents qmldircomponentsnetwork;
+ if (QDeclarativeCompositeTypeResource *resource
+ = resources.value(unit->imports.baseUrl().resolved(QUrl(QLatin1String("./qmldir"))))) {
+ QDeclarativeDirParser parser;
+ parser.setSource(QString::fromUtf8(resource->data));
+ parser.parse();
+ qmldircomponentsnetwork = parser.components();
+ }
+
+ QDeclarativeEnginePrivate::get(engine)->
+ addToImport(&unit->imports,
+ qmldircomponentsnetwork,
+ QLatin1String("."),
+ QString(),
+ -1, -1,
+ QDeclarativeScriptParser::Import::File,
+ 0); // error ignored (just means no fallback)
+ }
+
foreach (QDeclarativeScriptParser::Import imp, unit->data.imports()) {
QDeclarativeDirComponents qmldircomponentsnetwork;
@@ -587,31 +612,6 @@ 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.
- */
- {
-
- QDeclarativeDirComponents qmldircomponentsnetwork;
- if (QDeclarativeCompositeTypeResource *resource
- = resources.value(unit->imports.baseUrl().resolved(QUrl(QLatin1String("./qmldir"))))) {
- QDeclarativeDirParser parser;
- parser.setSource(QString::fromUtf8(resource->data));
- parser.parse();
- qmldircomponentsnetwork = parser.components();
- }
-
- QDeclarativeEnginePrivate::get(engine)->
- addToImport(&unit->imports,
- qmldircomponentsnetwork,
- QLatin1String("."),
- QString(),
- -1, -1,
- QDeclarativeScriptParser::Import::File,
- 0); // error ignored (just means no fallback)
- }
-
QList<QDeclarativeScriptParser::TypeReference*> types = unit->data.referencedTypes();
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/LocalLast.qml b/tests/auto/declarative/qdeclarativelanguage/data/LocalLast.qml
new file mode 100644
index 0000000..a0706ad
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/LocalLast.qml
@@ -0,0 +1,2 @@
+import Qt 4.6
+Text {}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/LocalLast.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/LocalLast.qml
new file mode 100644
index 0000000..d8a22a8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/LocalLast.qml
@@ -0,0 +1,2 @@
+import Qt 4.6
+Rectangle {}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir
index eeb9a05..0adb0f6 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir
+++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir
@@ -1,4 +1,5 @@
Rectangle 1.5 InstalledTest2.qml
+LocalLast 1.0 LocalLast.qml
InstalledTest 1.4 InstalledTest2.qml
InstalledTest 1.0 InstalledTest.qml
InstalledTestTP 0.0 InstalledTest.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index 0f11498..722e161 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -1357,6 +1357,13 @@ void tst_qdeclarativelanguage::importsOrder_data()
"import com.nokia.installedtest 1.5\n"
"Rectangle.Image {}"
<< "QDeclarativeImage";
+ QTest::newRow("local last 1") <<
+ "LocalLast {}"
+ << "QDeclarativeText";
+ QTest::newRow("local last 2") <<
+ "import com.nokia.installedtest 1.0\n"
+ "LocalLast {}"
+ << "QDeclarativeRectangle"; // i.e. from com.nokia.installedtest, not data/LocalLast.qml
}
void tst_qdeclarativelanguage::importsOrder()