diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-03-10 05:14:06 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-03-10 05:14:06 (GMT) |
commit | df1e179df5a8607bdf97fff901e2156efcc48623 (patch) | |
tree | fc01537d24e3cc437b59babe3f8ca12f0e6f910c /src/declarative/util/qdeclarativefontloader.cpp | |
parent | 63ac95323b3fb8884f8d7ede0ebf4e360393f658 (diff) | |
download | Qt-df1e179df5a8607bdf97fff901e2156efcc48623.zip Qt-df1e179df5a8607bdf97fff901e2156efcc48623.tar.gz Qt-df1e179df5a8607bdf97fff901e2156efcc48623.tar.bz2 |
URL redirection for font loader
Task-number: QTBUG-7515
Diffstat (limited to 'src/declarative/util/qdeclarativefontloader.cpp')
-rw-r--r-- | src/declarative/util/qdeclarativefontloader.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp index 8f5f537..0509242 100644 --- a/src/declarative/util/qdeclarativefontloader.cpp +++ b/src/declarative/util/qdeclarativefontloader.cpp @@ -61,7 +61,7 @@ class QDeclarativeFontLoaderPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QDeclarativeFontLoader) public: - QDeclarativeFontLoaderPrivate() : reply(0), status(QDeclarativeFontLoader::Null) {} + QDeclarativeFontLoaderPrivate() : reply(0), status(QDeclarativeFontLoader::Null), redirectCount(0) {} void addFontToDatabase(const QByteArray &); @@ -69,6 +69,7 @@ public: QString name; QNetworkReply *reply; QDeclarativeFontLoader::Status status; + int redirectCount; }; @@ -206,10 +207,25 @@ QDeclarativeFontLoader::Status QDeclarativeFontLoader::status() const return d->status; } +#define FONTLOADER_MAXIMUM_REDIRECT_RECURSION 16 + void QDeclarativeFontLoader::replyFinished() { Q_D(QDeclarativeFontLoader); if (d->reply) { + d->redirectCount++; + if (d->redirectCount < FONTLOADER_MAXIMUM_REDIRECT_RECURSION) { + QVariant redirect = d->reply->attribute(QNetworkRequest::RedirectionTargetAttribute); + if (redirect.isValid()) { + QUrl url = d->reply->url().resolved(redirect.toUrl()); + d->reply->deleteLater(); + d->reply = 0; + setSource(url); + return; + } + } + d->redirectCount=0; + if (!d->reply->error()) { QByteArray ba = d->reply->readAll(); d->addFontToDatabase(ba); |