summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2011-02-11 01:33:37 (GMT)
committerBea Lam <bea.lam@nokia.com>2011-02-11 03:08:39 (GMT)
commit33512bc223be373975426ffcc6f8fa783a7582c9 (patch)
treec92b5b47837e89bcaea472495cf243b21a362c73
parent974db3ce58307069fcafdee2c5636ff72b061134 (diff)
downloadQt-33512bc223be373975426ffcc6f8fa783a7582c9.zip
Qt-33512bc223be373975426ffcc6f8fa783a7582c9.tar.gz
Qt-33512bc223be373975426ffcc6f8fa783a7582c9.tar.bz2
Make addImportPath() work for windows paths starting with lower case
Was causing assert failure on windows if the 'c:' was lower case, since it was being added to the import path database with a lower case and thus later lookups with an upper case 'c:' would fail. This change fixes the check for whether the path refers to a local path or not. Task-number: QTBUG-16885 Change-Id: I0a2a2f705443ed453fb2b13f8599e035c2bd2877 Reviewed-by: Martin Jones
-rw-r--r--src/declarative/qml/qdeclarativeimport.cpp6
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp12
2 files changed, 15 insertions, 3 deletions
diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp
index 87183c4..244f2ad 100644
--- a/src/declarative/qml/qdeclarativeimport.cpp
+++ b/src/declarative/qml/qdeclarativeimport.cpp
@@ -952,7 +952,8 @@ void QDeclarativeImportDatabase::addPluginPath(const QString& path)
qDebug().nospace() << "QDeclarativeImportDatabase::addPluginPath: " << path;
QUrl url = QUrl(path);
- if (url.isRelative() || url.scheme() == QLatin1String("file")) {
+ if (url.isRelative() || url.scheme() == QLatin1String("file")
+ || (url.scheme().length() == 1 && QFile::exists(path)) ) { // windows path
QDir dir = QDir(path);
filePluginPath.prepend(dir.canonicalPath());
} else {
@@ -974,7 +975,8 @@ void QDeclarativeImportDatabase::addImportPath(const QString& path)
QUrl url = QUrl(path);
QString cPath;
- if (url.isRelative() || url.scheme() == QLatin1String("file")) {
+ if (url.isRelative() || url.scheme() == QLatin1String("file")
+ || (url.scheme().length() == 1 && QFile::exists(path)) ) { // windows path
QDir dir = QDir(path);
cPath = dir.canonicalPath();
} else {
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
index 9ec0f84..8e31fd1 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
@@ -191,8 +191,18 @@ void tst_qdeclarativemoduleplugin::incorrectPluginCase()
void tst_qdeclarativemoduleplugin::importPluginWithQmlFile()
{
+ QString path = QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports");
+
+ // QTBUG-16885: adding an import path with a lower-case "c:" causes assert failure
+ // (this only happens if the plugin includes pure QML files)
+ #ifdef Q_OS_WIN
+ QVERIFY(path.at(0).isUpper() && path.at(1) == QLatin1Char(':'));
+ path = path.at(0).toLower() + path.mid(1);
+ #endif
+
QDeclarativeEngine engine;
- engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports"));
+ engine.addImportPath(path);
+
QDeclarativeComponent component(&engine, TEST_FILE("data/pluginWithQmlFile.qml"));
foreach (QDeclarativeError err, component.errors())
qWarning() << err;