diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-04-08 02:21:44 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-04-08 02:21:44 (GMT) |
commit | a51eb694a9a43227733dbfc4373779d84d435144 (patch) | |
tree | c10d1065e3dde9a8adaabbb9b6ae4ab8edff897c | |
parent | 2f163cda817a3318c293e9a9b9e66fb20f4c990c (diff) | |
download | Qt-a51eb694a9a43227733dbfc4373779d84d435144.zip Qt-a51eb694a9a43227733dbfc4373779d84d435144.tar.gz Qt-a51eb694a9a43227733dbfc4373779d84d435144.tar.bz2 |
Give error if attempt to import from a version that is not installed.
(was done for builtins/plugins, but now also for qmldir-specified content)
Task-number: QTBUG-9627
-rw-r--r-- | src/declarative/qml/qdeclarativeengine.cpp | 12 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp | 11 |
2 files changed, 20 insertions, 3 deletions
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index e8b6913..f5fe140 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1620,6 +1620,18 @@ public: url.chop(1); } + if (vmaj > -1 && vmin > -1 && !qmldircomponents.isEmpty()) { + QList<QDeclarativeDirParser::Component>::ConstIterator it = qmldircomponents.begin(); + for (; it != qmldircomponents.end(); ++it) { + if (it->majorVersion > vmaj || (it->majorVersion == vmaj && it->minorVersion >= vmin)) + break; + } + if (it == qmldircomponents.end()) { + *errorString = QDeclarativeEngine::tr("module \"%1\" version %2.%3 is not installed").arg(uri_arg).arg(vmaj).arg(vmin); + return false; + } + } + s->uris.prepend(uri); s->urls.prepend(url); s->majversions.prepend(vmaj); diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 8990fb4..dcd72d2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -1347,11 +1347,16 @@ void tst_qdeclarativelanguage::importsInstalled_data() "InstalledTest {}" << "QDeclarativeText" << ""; - QTest::newRow("installed import 4") + QTest::newRow("installed import minor version not available") // QTBUG-9627 << "import com.nokia.installedtest 1.10\n" "InstalledTest {}" - << "QDeclarativeText" - << ""; + << "" + << "module \"com.nokia.installedtest\" version 1.10 is not installed"; + QTest::newRow("installed import major version not available") // QTBUG-9627 + << "import com.nokia.installedtest 9.0\n" + "InstalledTest {}" + << "" + << "module \"com.nokia.installedtest\" version 9.0 is not installed"; QTest::newRow("installed import visibility") // QT-614 << "import com.nokia.installedtest 1.4\n" "PrivateType {}" |