summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2010-03-18 14:54:02 (GMT)
committermae <qt-info@nokia.com>2010-03-19 15:18:53 (GMT)
commitd039e2e8307bd272eedc5beae4ecf1a14e47def5 (patch)
tree992d9b32eb494c3636ac7b09ecb6442d4ea0441f /src/declarative/qml
parent7ac2e0cf47628c5a7ea08a5e3058c8bc55fbdd46 (diff)
downloadQt-d039e2e8307bd272eedc5beae4ecf1a14e47def5.zip
Qt-d039e2e8307bd272eedc5beae4ecf1a14e47def5.tar.gz
Qt-d039e2e8307bd272eedc5beae4ecf1a14e47def5.tar.bz2
Fix local type lookup
This change removes the hacky final baseUrl+TypeName+".qml" lookup. In order to still support internal files in remote modules, a new qmldir keyword "internal" is introduced.
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qdeclarativedirparser.cpp10
-rw-r--r--src/declarative/qml/qdeclarativedirparser_p.h6
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp23
3 files changed, 24 insertions, 15 deletions
diff --git a/src/declarative/qml/qdeclarativedirparser.cpp b/src/declarative/qml/qdeclarativedirparser.cpp
index b6d2115..0e82098 100644
--- a/src/declarative/qml/qdeclarativedirparser.cpp
+++ b/src/declarative/qml/qdeclarativedirparser.cpp
@@ -151,6 +151,16 @@ bool QDeclarativeDirParser::parse()
_plugins.append(entry);
+ } else if (sections[0] == QLatin1String("internal")) {
+ if (sectionCount != 3) {
+ reportError(lineNumber, -1,
+ QString::fromUtf8("internal types require 2 arguments, but %1 were provided").arg(sectionCount + 1));
+ continue;
+ }
+ Component entry(sections[1], sections[2], -1, -1);
+ entry.internal = true;
+ _components.append(entry);
+
} else if (sectionCount == 2) {
// No version specified (should only be used for relative qmldir files)
const Component entry(sections[0], sections[1], -1, -1);
diff --git a/src/declarative/qml/qdeclarativedirparser_p.h b/src/declarative/qml/qdeclarativedirparser_p.h
index 5df7117..295fa66 100644
--- a/src/declarative/qml/qdeclarativedirparser_p.h
+++ b/src/declarative/qml/qdeclarativedirparser_p.h
@@ -94,15 +94,17 @@ public:
struct Component
{
Component()
- : majorVersion(0), minorVersion(0) {}
+ : majorVersion(0), minorVersion(0), internal(false) {}
Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion)
- : typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion) {}
+ : typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion),
+ internal(false) {}
QString typeName;
QString fileName;
int majorVersion;
int minorVersion;
+ bool internal;
};
QList<Component> components() const;
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 800434a..174579c 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -1363,7 +1363,8 @@ struct QDeclarativeEnginePrivate::ImportedNamespace {
QList<bool> isLibrary;
QList<QString> qmlDirContent;
- bool find(const QByteArray& type, int *vmajor, int *vminor, QDeclarativeType** type_return, QUrl* url_return)
+ bool find(const QByteArray& type, int *vmajor, int *vminor, QDeclarativeType** type_return, QUrl* url_return,
+ QUrl *base = 0)
{
for (int i=0; i<urls.count(); ++i) {
int vmaj = majversions.at(i);
@@ -1398,8 +1399,13 @@ struct QDeclarativeEnginePrivate::ImportedNamespace {
if (c.typeName == typeName) {
typeWasDeclaredInQmldir = true;
if (c.majorVersion < vmaj || (c.majorVersion == vmaj && vmin >= c.minorVersion)) {
+ QUrl candidate = url.resolved(QUrl(c.fileName));
+ if (c.internal && base) {
+ if (base->resolved(QUrl(c.fileName)) != candidate)
+ continue; // failed attempt to access an internal type
+ }
if (url_return)
- *url_return = url.resolved(QUrl(c.fileName));
+ *url_return = candidate;
return true;
}
}
@@ -1617,7 +1623,7 @@ public:
}
QByteArray unqualifiedtype = slash < 0 ? type : type.mid(slash+1); // common-case opt (QString::mid works fine, but slower)
if (s) {
- if (s->find(unqualifiedtype,vmajor,vminor,type_return,url_return))
+ if (s->find(unqualifiedtype,vmajor,vminor,type_return,url_return, &base))
return true;
if (s->urls.count() == 1 && !s->isLibrary[0] && url_return && s != &unqualifiedset) {
// qualified, and only 1 url
@@ -1627,16 +1633,7 @@ public:
}
-
- /* now comes really nasty code. It makes "private" types load in the remote case, but
- it does this by breaking the import order. This must go. Instead private types must
- be marked private in the qmldir. */
- if (url_return) {
- *url_return = base.resolved(QUrl(QString::fromUtf8(type + ".qml")));
- return true;
- } else {
- return false;
- }
+ return false;
}
QDeclarativeEnginePrivate::ImportedNamespace *findNamespace(const QString& type)