summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-07-05 23:59:41 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2010-07-13 05:16:36 (GMT)
commit174216f57b881ff1ab9d7df8bdbb5e2564df51b0 (patch)
tree1232b21372ce74c59fe03ca51553491305a2e856
parent4f9b0f34c985c810da5027d245515d8c66191881 (diff)
downloadQt-174216f57b881ff1ab9d7df8bdbb5e2564df51b0.zip
Qt-174216f57b881ff1ab9d7df8bdbb5e2564df51b0.tar.gz
Qt-174216f57b881ff1ab9d7df8bdbb5e2564df51b0.tar.bz2
Fix inconsistent reporting of module import errors when using versions.
Task-number: QTBUG-11936 (cherry picked from commit cabdb16f5ea6458dec9a2ec3b70a01e498b27dbc)
-rw-r--r--doc/src/declarative/modules.qdoc11
-rw-r--r--src/declarative/qml/qdeclarativeimport.cpp18
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/qmldir2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp9
7 files changed, 37 insertions, 8 deletions
diff --git a/doc/src/declarative/modules.qdoc b/doc/src/declarative/modules.qdoc
index 02a2f5f..36570da 100644
--- a/doc/src/declarative/modules.qdoc
+++ b/doc/src/declarative/modules.qdoc
@@ -103,9 +103,16 @@ the \c qmldir file. Types which you do not wish to export to users of your modul
may be marked with the \c internal keyword: \c internal <TypeName> <File>.
The same type can be provided by different files in different versions, in which
-case later earlier versions (eg. 1.2) must precede earlier versions (eg. 1.0),
+case later versions (eg. 1.2) must precede earlier versions (eg. 1.0),
since the \e first name-version match is used and a request for a version of a type
-can be fulfilled by one defined in an earlier version of the module.
+can be fulfilled by one defined in an earlier version of the module. If a user attempts
+to import a version earlier than the earliest provided or later than the latest provided,
+an error results, but if the user imports a version within the range of versions provided,
+even if no type is specific to that version, no error results.
+
+A single module, in all versions, may only be provided in a single directory (and a single \c qmldir file).
+If multiple are provided, only the first in the search path will be used (regardless of whether other versions
+are provided by directories later in the search path).
Installed and remote files without a namespace \e must be referred to by version information described above,
local files \e may have it.
diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp
index a2e3831..e917cf6 100644
--- a/src/declarative/qml/qdeclarativeimport.cpp
+++ b/src/declarative/qml/qdeclarativeimport.cpp
@@ -445,11 +445,23 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp
if (vmaj > -1 && vmin > -1 && !qmldircomponents.isEmpty()) {
QList<QDeclarativeDirParser::Component>::ConstIterator it = qmldircomponents.begin();
+ int lowest_maj = INT_MAX;
+ int lowest_min = INT_MAX;
+ int highest_maj = INT_MIN;
+ int highest_min = INT_MIN;
for (; it != qmldircomponents.end(); ++it) {
- if (it->majorVersion > vmaj || (it->majorVersion == vmaj && it->minorVersion >= vmin))
- break;
+ if (it->majorVersion > highest_maj || (it->majorVersion == highest_maj && it->minorVersion > highest_min)) {
+ highest_maj = it->majorVersion;
+ highest_min = it->minorVersion;
+ }
+ if (it->majorVersion < lowest_maj || (it->majorVersion == lowest_maj && it->minorVersion < lowest_min)) {
+ lowest_maj = it->majorVersion;
+ lowest_min = it->minorVersion;
+ }
}
- if (it == qmldircomponents.end()) {
+ if (lowest_maj > vmaj || (lowest_maj == vmaj && lowest_min > vmin)
+ || highest_maj < vmaj || (highest_maj == vmaj && highest_min < vmin))
+ {
*errorString = QDeclarativeImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri_arg).arg(vmaj).arg(vmin);
return false;
}
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 0adb0f6..d15720a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir
+++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir
@@ -2,4 +2,3 @@ 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/data/lib/com/nokia/installedtest0/InstalledTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml
new file mode 100644
index 0000000..303b5a5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml
@@ -0,0 +1,2 @@
+import Qt 4.7 as Qt47
+Qt47.Rectangle {}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml
new file mode 100644
index 0000000..8c953cb
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml
@@ -0,0 +1,2 @@
+import Qt 4.7
+Text {}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/qmldir b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/qmldir
new file mode 100644
index 0000000..b301226
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/qmldir
@@ -0,0 +1,2 @@
+InstalledTest 1.4 InstalledTest2.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 3ce356e..e687ba0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -1476,12 +1476,12 @@ void tst_qdeclarativelanguage::importsInstalled_data()
// import installed
QTest::newRow("installed import 0")
- << "import com.nokia.installedtest 0.0\n"
+ << "import com.nokia.installedtest0 0.0\n"
"InstalledTestTP {}"
<< "QDeclarativeRectangle"
<< "";
QTest::newRow("installed import 0 as TP")
- << "import com.nokia.installedtest 0.0 as TP\n"
+ << "import com.nokia.installedtest0 0.0 as TP\n"
"TP.InstalledTestTP {}"
<< "QDeclarativeRectangle"
<< "";
@@ -1500,6 +1500,11 @@ void tst_qdeclarativelanguage::importsInstalled_data()
"InstalledTest {}"
<< "QDeclarativeText"
<< "";
+ QTest::newRow("installed import minor version not available") // QTBUG-11936
+ << "import com.nokia.installedtest 0.1\n"
+ "InstalledTest {}"
+ << ""
+ << "module \"com.nokia.installedtest\" version 0.1 is not installed";
QTest::newRow("installed import minor version not available") // QTBUG-9627
<< "import com.nokia.installedtest 1.10\n"
"InstalledTest {}"