diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-17 13:44:16 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-17 13:44:16 (GMT) |
commit | b3cddbcf92a20585fd6fcd0a6c200c5e94b8669f (patch) | |
tree | e476d17d94feb127f6e34fa46cfde4b763d50f77 /src/declarative/util/qdeclarativepixmapcache.cpp | |
parent | 4c1f54097a1fb1acff817ba8caa8af347ae56cd2 (diff) | |
parent | ca8231566ac3804e479502d082871ab8ca28b8bb (diff) | |
download | Qt-b3cddbcf92a20585fd6fcd0a6c200c5e94b8669f.zip Qt-b3cddbcf92a20585fd6fcd0a6c200c5e94b8669f.tar.gz Qt-b3cddbcf92a20585fd6fcd0a6c200c5e94b8669f.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (132 commits)
Fix auto test
Fix type lookup with url
Fix default values on Textinput
Add an implicit import "." to types loaded from a local url
Fix crash
Don't use Qt3 support methods.
Crash
Add/delete albums in photoviewer.
Emits itemsRemoved() in QDeclarativeListModel::remove.
Readd the itemtree benchmarks for comparison purposes.
Allow enum constants as list element properties.
Compile
Cleanup benchmark a little
Really fix warning.
Fix warnings.
MouseArea works now with any QGraphicsObject
Make states test work with smaller font size.
Register QGraphicsWidget type.
Add ListView and GridView.indexAt() methods to get the index at a point.
Tests for default count(), get() values should be run on the worker
...
Diffstat (limited to 'src/declarative/util/qdeclarativepixmapcache.cpp')
-rw-r--r-- | src/declarative/util/qdeclarativepixmapcache.cpp | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index cfb25dd..942d5f6 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -137,7 +137,7 @@ class QDeclarativeImageRequestHandler : public QObject Q_OBJECT public: QDeclarativeImageRequestHandler(QDeclarativeImageReader *read, QDeclarativeEngine *eng) - : QObject(), accessManager(0), engine(eng), reader(read) + : QObject(), accessManager(0), engine(eng), reader(read), redirectCount(0) { QCoreApplication::postEvent(this, new QEvent(QEvent::User)); } @@ -162,18 +162,24 @@ private: QNetworkAccessManager *accessManager; QDeclarativeEngine *engine; QDeclarativeImageReader *reader; + int redirectCount; + + static int replyDownloadProgress; + static int replyFinished; + static int downloadProgress; + static int thisNetworkRequestDone; }; //=========================================================================== +int QDeclarativeImageRequestHandler::replyDownloadProgress = -1; +int QDeclarativeImageRequestHandler::replyFinished = -1; +int QDeclarativeImageRequestHandler::downloadProgress = -1; +int QDeclarativeImageRequestHandler::thisNetworkRequestDone = -1; + bool QDeclarativeImageRequestHandler::event(QEvent *event) { if (event->type() == QEvent::User) { - static int replyDownloadProgress = -1; - static int replyFinished = -1; - static int downloadProgress = -1; - static int thisNetworkRequestDone = -1; - if (replyDownloadProgress == -1) { replyDownloadProgress = QNetworkReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)"); replyFinished = QNetworkReply::staticMetaObject.indexOfSignal("finished()"); @@ -264,10 +270,33 @@ bool QDeclarativeImageRequestHandler::event(QEvent *event) return QObject::event(event); } +#define IMAGEREQUESTHANDLER_MAX_REDIRECT_RECURSION 16 + void QDeclarativeImageRequestHandler::networkRequestDone() { QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); QDeclarativePixmapReply *job = replies.take(reply); + + redirectCount++; + if (redirectCount < IMAGEREQUESTHANDLER_MAX_REDIRECT_RECURSION) { + QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); + if (redirect.isValid()) { + QUrl url = reply->url().resolved(redirect.toUrl()); + QNetworkRequest req(url); + req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); + + reply->deleteLater(); + reply = networkAccessManager()->get(req); + + QMetaObject::connect(reply, replyDownloadProgress, job, downloadProgress); + QMetaObject::connect(reply, replyFinished, this, thisNetworkRequestDone); + + replies.insert(reply, job); + return; + } + } + redirectCount=0; + if (job) { QImage image; QDeclarativeImageReaderEvent::ReadError error; |