diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-03-10 06:20:01 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-03-10 06:20:01 (GMT) |
commit | 099d63fd9b4017b8e02b2cfaae82f29c0c0d294f (patch) | |
tree | ed82b4be7ba880d3ec604e9bce26a998e36ba5d2 /src/declarative/qml | |
parent | 46dfe1e6dad1f3a74cb15bfd538e9fe28ffac5b3 (diff) | |
parent | b0fb09d29675f701f02fe5bf91fe64ffd0008cf6 (diff) | |
download | Qt-099d63fd9b4017b8e02b2cfaae82f29c0c0d294f.zip Qt-099d63fd9b4017b8e02b2cfaae82f29c0c0d294f.tar.gz Qt-099d63fd9b4017b8e02b2cfaae82f29c0c0d294f.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src/declarative/qml')
4 files changed, 57 insertions, 3 deletions
diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp index b90a598..9b3a8b4 100644 --- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp +++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp @@ -154,7 +154,7 @@ QDeclarativeCompositeTypeData::TypeReference::TypeReference() } QDeclarativeCompositeTypeManager::QDeclarativeCompositeTypeManager(QDeclarativeEngine *e) -: engine(e) +: engine(e), redirectCount(0) { } @@ -172,6 +172,10 @@ QDeclarativeCompositeTypeManager::~QDeclarativeCompositeTypeManager() QDeclarativeCompositeTypeData *QDeclarativeCompositeTypeManager::get(const QUrl &url) { + Redirects::Iterator redir = redirects.find(url); + if (redir != redirects.end()) + return get(*redir); + QDeclarativeCompositeTypeData *unit = components.value(url); if (!unit) { @@ -219,6 +223,8 @@ void QDeclarativeCompositeTypeManager::clearCache() } } +#define TYPEMANAGER_MAXIMUM_REDIRECT_RECURSION 16 + void QDeclarativeCompositeTypeManager::replyFinished() { QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); @@ -226,6 +232,26 @@ void QDeclarativeCompositeTypeManager::replyFinished() QDeclarativeCompositeTypeData *unit = components.value(reply->url()); Q_ASSERT(unit); + redirectCount++; + if (redirectCount < TYPEMANAGER_MAXIMUM_REDIRECT_RECURSION) { + QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); + if (redirect.isValid()) { + QUrl url = reply->url().resolved(redirect.toUrl()); + redirects.insert(reply->url(),url); + unit->imports.setBaseUrl(url); + components.remove(reply->url()); + components.insert(url, unit); + reply->deleteLater(); + reply = engine->networkAccessManager()->get(QNetworkRequest(url)); + QObject::connect(reply, SIGNAL(finished()), + this, SLOT(replyFinished())); + QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)), + this, SLOT(requestProgress(qint64,qint64))); + return; + } + } + redirectCount = 0; + if (reply->error() != QNetworkReply::NoError) { QString errorDescription; // ### - Fill in error @@ -256,6 +282,24 @@ void QDeclarativeCompositeTypeManager::resourceReplyFinished() QDeclarativeCompositeTypeResource *resource = resources.value(reply->url()); Q_ASSERT(resource); + redirectCount++; + if (redirectCount < TYPEMANAGER_MAXIMUM_REDIRECT_RECURSION) { + QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); + if (redirect.isValid()) { + QUrl url = reply->url().resolved(redirect.toUrl()); + redirects.insert(reply->url(),url); + resource->url = url.toString(); + resources.remove(reply->url()); + resources.insert(url, resource); + reply->deleteLater(); + reply = engine->networkAccessManager()->get(QNetworkRequest(url)); + QObject::connect(reply, SIGNAL(finished()), + this, SLOT(resourceReplyFinished())); + return; + } + } + redirectCount = 0; + if (reply->error() != QNetworkReply::NoError) { resource->status = QDeclarativeCompositeTypeResource::Error; @@ -546,6 +590,10 @@ int QDeclarativeCompositeTypeManager::resolveTypes(QDeclarativeCompositeTypeData continue; } + Redirects::Iterator redir = redirects.find(url); + if (redir != redirects.end()) + url = *redir; + QDeclarativeCompositeTypeData *urlUnit = components.value(url); if (!urlUnit) { diff --git a/src/declarative/qml/qdeclarativecompositetypemanager_p.h b/src/declarative/qml/qdeclarativecompositetypemanager_p.h index 03d16b8..a572e0c 100644 --- a/src/declarative/qml/qdeclarativecompositetypemanager_p.h +++ b/src/declarative/qml/qdeclarativecompositetypemanager_p.h @@ -109,6 +109,9 @@ private: Components components; typedef QHash<QUrl, QDeclarativeCompositeTypeResource *> Resources; Resources resources; + typedef QHash<QUrl, QUrl> Redirects; + Redirects redirects; + int redirectCount; }; QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativedirparser.cpp b/src/declarative/qml/qdeclarativedirparser.cpp index e730b92..b6d2115 100644 --- a/src/declarative/qml/qdeclarativedirparser.cpp +++ b/src/declarative/qml/qdeclarativedirparser.cpp @@ -151,13 +151,16 @@ bool QDeclarativeDirParser::parse() _plugins.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); + _components.append(entry); } else if (sectionCount == 3) { const QString &version = sections[1]; const int dotIndex = version.indexOf(QLatin1Char('.')); if (dotIndex == -1) { qWarning() << "expected '.'"; // ### use reportError - } else if (version.indexOf(QLatin1Char('.'), dotIndex + 1) != -1) { qWarning() << "unexpected '.'"; // ### use reportError diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp index 87cab85..58e67fa 100644 --- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp +++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp @@ -1245,7 +1245,7 @@ void QDeclarativeXMLHttpRequest::finished() if (m_redirectCount < XMLHTTPREQUEST_MAXIMUM_REDIRECT_RECURSION) { QVariant redirect = m_network->attribute(QNetworkRequest::RedirectionTargetAttribute); if (redirect.isValid()) { - QUrl url = redirect.toUrl(); + QUrl url = m_network->url().resolved(redirect.toUrl()); destroyNetwork(); requestFromUrl(url); return; |