From 33512bc223be373975426ffcc6f8fa783a7582c9 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 11 Feb 2011 11:33:37 +1000 Subject: 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 --- src/declarative/qml/qdeclarativeimport.cpp | 6 ++++-- .../tst_qdeclarativemoduleplugin.cpp | 12 +++++++++++- 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; -- cgit v0.12