summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2011-02-11 01:33:37 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2011-02-14 14:02:36 (GMT)
commitd21432f721add7d74a1c9e6309aea53886e18eab (patch)
treeb4207d5bc67f947462f67e6d01b942260e9711c8
parent7708808ccc0637541f4cdf1c7370239a8d150d67 (diff)
downloadQt-d21432f721add7d74a1c9e6309aea53886e18eab.zip
Qt-d21432f721add7d74a1c9e6309aea53886e18eab.tar.gz
Qt-d21432f721add7d74a1c9e6309aea53886e18eab.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 (cherry picked from commit 33512bc223be373975426ffcc6f8fa783a7582c9)
-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;