diff options
author | DUI-Team Symbio <dui-team@fi.symbio.com> | 2010-06-24 14:10:05 +0300 |
---|---|---|
committer | Daniel d'Andrada <daniel.dandrada@nokia.com> | 2010-06-30 11:26:47 +0300 |
commit | 78d118620b2e84b773c8a0701bc8722b80989c61 (patch) | |
tree | 4ccd69e9b100ea0d149ed97c2140dbe9256abac5 | |
parent | e96b3ba38443719ff3d5f6f5325fdc8b6cc5c647 (diff) |
Fixes: NB#174927 - MTheme::pixmap() and MTheme::pixmapCopy() return empty images
RevBy: Armin Berres
Details:
Ensure that the copied pixmap is really loaded, dont just blindly return the
locally cached pixmap.
-rw-r--r-- | src/corelib/theme/mtheme.cpp | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/src/corelib/theme/mtheme.cpp b/src/corelib/theme/mtheme.cpp index 9f24ecde..e86ee436 100644 --- a/src/corelib/theme/mtheme.cpp +++ b/src/corelib/theme/mtheme.cpp @@ -250,32 +250,23 @@ QPixmap *MTheme::pixmapCopy(const QString &id, const QSize &size) if (realSize.height() < 1) realSize.rheight() = 0; + // if there is no entry for the copied pixmap yet, we need to create it QString identifier = defaultPixmapCacheId(id, realSize.width(), realSize.height()); const QPixmap *p = instance()->d_ptr->fetchPixmapFromCache(identifier); - - // check if we found the pixmap from cache? - if (p) { - return new QPixmap(p->copy()); + if (!p) { + QPixmap *result = new QPixmap(); + instance()->d_ptr->pixmapIdentifiers.insert(identifier, CachedPixmap(result, id, realSize)); + p = result; } - QPixmap *result; - // we have to create temporary pixmap - if (realSize.width() < 1 || realSize.height() < 1) { - result = new QPixmap(1, 1); - } else { - result = new QPixmap(realSize); - } - if (instance()->d_ptr->showAsyncRequests) { - result->fill(QColor(0, 255, 0, 255)); - } else { - result->fill(QColor(0, 0, 0, 0)); - } + //TODO: check if the local pixmap pointer is valid already, + // no need to fetch anything from daemon then - instance()->d_ptr->pixmapIdentifiers.insert(identifier, CachedPixmap(result, id, realSize)); + //force daemon to load the pixmap synchronously, then make copy of the + //pixmap and release it immediately instance()->d_ptr->themeDaemon->pixmapHandleSync(id, realSize); - - QPixmap *copy = new QPixmap(result->copy()); - releasePixmap(result); + QPixmap* copy = new QPixmap(p->copy()); + releasePixmap(p); return copy; } |