summaryrefslogtreecommitdiffstats
path: root/src/declarative/util
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-01-20 05:08:41 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-01-20 05:08:41 (GMT)
commitb5e409d9043c8e013c2bd617fcd3605c1de29a92 (patch)
treeb49f95cbf7753903ee47c0fde9d2cc765ea5e7f2 /src/declarative/util
parentacc74925e989e9c6cbde66858ca04cfc053602bc (diff)
parentf418df448f6f57d1fcc91fd6688b5fdb81b996fa (diff)
downloadQt-b5e409d9043c8e013c2bd617fcd3605c1de29a92.zip
Qt-b5e409d9043c8e013c2bd617fcd3605c1de29a92.tar.gz
Qt-b5e409d9043c8e013c2bd617fcd3605c1de29a92.tar.bz2
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/util')
-rw-r--r--src/declarative/util/qmlpixmapcache.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp
index 130d646..4c1d448 100644
--- a/src/declarative/util/qmlpixmapcache.cpp
+++ b/src/declarative/util/qmlpixmapcache.cpp
@@ -60,6 +60,11 @@
QT_BEGIN_NAMESPACE
+inline uint qHash(const QUrl &uri)
+{
+ return qHash(uri.toEncoded(QUrl::FormattingOption(0x100)));
+}
+
class QmlImageReader : public QThread
{
Q_OBJECT
@@ -216,7 +221,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 +341,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 +390,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 +416,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 +439,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 +455,7 @@ void QmlPixmapCache::cancel(const QUrl& url, QObject *obj)
*/
int QmlPixmapCache::pendingRequests()
{
- return qmlActivePixmapReplies.count();
+ return qmlActivePixmapReplies()->count();
}
#include <qmlpixmapcache.moc>