diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-08-19 05:40:41 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-08-19 05:40:41 (GMT) |
commit | a48e06bc745afae421d9f91c7143dd1a49906c77 (patch) | |
tree | f4f81ddc8435f8dd24b4a1470f1bf3abe97d31c7 /src/declarative | |
parent | b1e8d7aacf86e0ae5cb4910905c61dad434fe934 (diff) | |
download | Qt-a48e06bc745afae421d9f91c7143dd1a49906c77.zip Qt-a48e06bc745afae421d9f91c7143dd1a49906c77.tar.gz Qt-a48e06bc745afae421d9f91c7143dd1a49906c77.tar.bz2 |
tighten installed importing
still not per-spec
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 558bd49..a92ec0f 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -1054,37 +1054,35 @@ struct QmlEnginePrivate::ImportedNamespace { QUrl url = QUrl(urls.at(i) + QLatin1String("/") + type + QLatin1String(".qml")); int vmaj = majversions.at(i); int vmin = minversions.at(i); - // XXX search non-files too! (eg. zip files, see QT-524) - QFileInfo f(url.toLocalFile()); - if (f.exists()) { - bool ok=true; - if (vmaj || vmin) { - QString version = QString::number(vmaj) + QLatin1String(".") + QString::number(vmin); - ok=false; - // Check version file - XXX cache these in QmlEngine! - QFile qmldir(urls.at(i)+QLatin1String("/qmldir")); - if (qmldir.open(QIODevice::ReadOnly)) { - do { - QString line = QString::fromUtf8(qmldir.readLine()); - if (line.at(0) == QLatin1Char('#')) - continue; - int space1 = line.indexOf(QLatin1Char(' ')); - int space2 = space1 >=0 ? line.indexOf(QLatin1Char(' '),space1+1) : -1; - QStringRef maptype = line.leftRef(space1); - QStringRef mapversion = line.midRef(space1+1,space2<0?line.length()-space1-2:space2-space1-1); - QStringRef mapfile = space2<0 ? QStringRef() : line.midRef(space2+1,line.length()-space2-2); - if (maptype==type && mapversion==version) { - if (mapfile.isEmpty()) - return url; - else - return url.resolved(mapfile.toString()); - } - } while (!qmldir.atEnd()); - } + if (vmaj || vmin) { + QString version = QString::number(vmaj) + QLatin1String(".") + QString::number(vmin); + // Check version file - XXX cache these in QmlEngine! + QFile qmldir(QUrl(urls.at(i)+QLatin1String("/qmldir")).toLocalFile()); + if (qmldir.open(QIODevice::ReadOnly)) { + do { + QString line = QString::fromUtf8(qmldir.readLine()); + if (line.at(0) == QLatin1Char('#')) + continue; + int space1 = line.indexOf(QLatin1Char(' ')); + int space2 = space1 >=0 ? line.indexOf(QLatin1Char(' '),space1+1) : -1; + QStringRef maptype = line.leftRef(space1); + QStringRef mapversion = line.midRef(space1+1,space2<0?line.length()-space1-2:space2-space1-1); + QStringRef mapfile = space2<0 ? QStringRef() : line.midRef(space2+1,line.length()-space2-2); + if (maptype==type && mapversion==version) { + if (mapfile.isEmpty()) + return url; + else + return url.resolved(mapfile.toString()); + } + } while (!qmldir.atEnd()); } - if (ok) - return url; + return QUrl(); // no match for requested version } + + // XXX search non-files too! (eg. zip files, see QT-524) + QFileInfo f(url.toLocalFile()); + if (f.exists()) + return url; // (unversioned) local import } return QUrl(); } @@ -1133,7 +1131,7 @@ public: foreach (QString p, importPath) { QString dir = p+QLatin1Char('/')+url; if (QFile::exists(dir+QLatin1String("/qmldir"))) { - url = dir; + url = QLatin1String("file://")+dir; found = true; break; } |