From 6e8feab83fa9303b1345f4a27478ba3ee0316e86 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 1 Feb 2010 11:10:31 +1000 Subject: Ensure pixmaps can be retrieved even if they do not fit in the QPixmapCache. Fixes QT-2280 --- src/declarative/util/qmlpixmapcache.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp index 6f36cad..1f68512 100644 --- a/src/declarative/util/qmlpixmapcache.cpp +++ b/src/declarative/util/qmlpixmapcache.cpp @@ -293,7 +293,7 @@ bool QmlPixmapReply::event(QEvent *event) } else { qWarning() << "Error decoding" << d->urlKey; } - QPixmapCache::insert(d->urlKey, d->pixmap); + QPixmapCache::insert(d->urlKey, d->pixmap); // note: may fail (returns false) emit finished(); } return true; @@ -374,8 +374,14 @@ QmlPixmapReply::Status QmlPixmapCache::get(const QUrl& url, QPixmap *pixmap) #endif QString key = url.toString(); + QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies.find(key); - if (QPixmapCache::find(key, pixmap)) { + if (iter != qmlActivePixmapReplies.end() && (*iter)->status() == QmlPixmapReply::Ready) { + // Must check this, since QPixmapCache::insert may have failed. + *pixmap = (*iter)->d_func()->pixmap; + status = (*iter)->status(); + (*iter)->release(); + } else if (QPixmapCache::find(key, pixmap)) { if (iter != qmlActivePixmapReplies.end()) { status = (*iter)->status(); (*iter)->release(); -- cgit v0.12