diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-01-20 04:00:41 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-01-20 04:00:41 (GMT) |
commit | 3700ecf4236233fe73afbde671cfdc8e194a0125 (patch) | |
tree | 38c8f1b0fc2a554028be2761d92e4cbd4311d9da /src/declarative/util/qmlpixmapcache.cpp | |
parent | 810074e299f7b2826fbfb8b224082f455eab94e5 (diff) | |
download | Qt-3700ecf4236233fe73afbde671cfdc8e194a0125.zip Qt-3700ecf4236233fe73afbde671cfdc8e194a0125.tar.gz Qt-3700ecf4236233fe73afbde671cfdc8e194a0125.tar.bz2 |
Use Q_GLOBAL_STATIC for static global.
Diffstat (limited to 'src/declarative/util/qmlpixmapcache.cpp')
-rw-r--r-- | src/declarative/util/qmlpixmapcache.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp index 130d646..f18421c 100644 --- a/src/declarative/util/qmlpixmapcache.cpp +++ b/src/declarative/util/qmlpixmapcache.cpp @@ -216,7 +216,7 @@ static QString toLocalFileOrQrc(const QUrl& url) } typedef QHash<QUrl, QmlPixmapReply *> QmlPixmapReplyHash; -static QmlPixmapReplyHash qmlActivePixmapReplies; +Q_GLOBAL_STATIC(QmlPixmapReplyHash, qmlActivePixmapReplies); class QmlPixmapReplyPrivate : public QObjectPrivate { @@ -336,7 +336,7 @@ bool QmlPixmapReply::release(bool defer) Q_ASSERT(d->refCount > 0); --d->refCount; if (d->refCount == 0) { - qmlActivePixmapReplies.remove(d->url); + qmlActivePixmapReplies()->remove(d->url); if (defer) deleteLater(); else @@ -385,15 +385,15 @@ QmlPixmapReply::Status QmlPixmapCache::get(const QUrl& url, QPixmap *pixmap) QByteArray key = url.toEncoded(QUrl::FormattingOption(0x100)); QString strKey = QString::fromLatin1(key.constData(), key.count()); - QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies.find(url); + QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url); if (QPixmapCache::find(strKey, pixmap)) { - if (iter != qmlActivePixmapReplies.end()) { + if (iter != qmlActivePixmapReplies()->end()) { status = (*iter)->status(); (*iter)->release(); } else { status = pixmap->isNull() ? QmlPixmapReply::Error : QmlPixmapReply::Ready; } - } else if (iter != qmlActivePixmapReplies.end()) { + } else if (iter != qmlActivePixmapReplies()->end()) { status = QmlPixmapReply::Loading; } @@ -411,12 +411,12 @@ QmlPixmapReply::Status QmlPixmapCache::get(const QUrl& url, QPixmap *pixmap) */ QmlPixmapReply *QmlPixmapCache::request(QmlEngine *engine, const QUrl &url) { - QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies.find(url); - if (iter == qmlActivePixmapReplies.end()) { + QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url); + if (iter == qmlActivePixmapReplies()->end()) { QNetworkRequest req(url); req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); QmlPixmapReply *item = new QmlPixmapReply(url, engine->networkAccessManager()->get(req)); - iter = qmlActivePixmapReplies.insert(url, item); + iter = qmlActivePixmapReplies()->insert(url, item); } else { (*iter)->addRef(); } @@ -434,8 +434,8 @@ QmlPixmapReply *QmlPixmapCache::request(QmlEngine *engine, const QUrl &url) */ void QmlPixmapCache::cancel(const QUrl& url, QObject *obj) { - QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies.find(url); - if (iter == qmlActivePixmapReplies.end()) + QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url); + if (iter == qmlActivePixmapReplies()->end()) return; QmlPixmapReply *reply = *iter; @@ -450,7 +450,7 @@ void QmlPixmapCache::cancel(const QUrl& url, QObject *obj) */ int QmlPixmapCache::pendingRequests() { - return qmlActivePixmapReplies.count(); + return qmlActivePixmapReplies()->count(); } #include <qmlpixmapcache.moc> |