summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qpixmapcache.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-11-17 14:15:53 +0100
committerLiang Qi <liang.qi@qt.io>2016-11-17 14:43:26 +0100
commite5ac4afbf954a3e1616ce8543d46ddc668d0374f (patch)
treebe6d97001edebd5cb74c64aaf0010f3cc76a7293 /src/gui/image/qpixmapcache.cpp
parente3ed95dd44b95b6e9361b562807e711d7ce5a58b (diff)
parent03c1a6ac717e3c5693653a5e294214056bda970e (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts: mkspecs/features/mac/default_post.prf mkspecs/features/uikit/default_post.prf Change-Id: I2a6f783451f2ac9eb4c1a050f605435d2dacf218
Diffstat (limited to 'src/gui/image/qpixmapcache.cpp')
-rw-r--r--src/gui/image/qpixmapcache.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp
index 6d03332367..73448943e1 100644
--- a/src/gui/image/qpixmapcache.cpp
+++ b/src/gui/image/qpixmapcache.cpp
@@ -324,26 +324,23 @@ QPixmap *QPMCache::object(const QPixmapCache::Key &key) const
bool QPMCache::insert(const QString& key, const QPixmap &pixmap, int cost)
{
- QPixmapCache::Key cacheKey;
- QPixmapCache::Key oldCacheKey = cacheKeys.value(key);
+ QPixmapCache::Key &cacheKey = cacheKeys[key];
//If for the same key we add already a pixmap we should delete it
- if (oldCacheKey.d) {
- QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(oldCacheKey);
- cacheKeys.remove(key);
- }
+ if (cacheKey.d)
+ QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(cacheKey);
//we create a new key the old one has been removed
cacheKey = createKey();
bool success = QCache<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost);
if (success) {
- cacheKeys.insert(key, cacheKey);
if (!theid) {
theid = startTimer(flush_time);
t = false;
}
} else {
//Insertion failed we released the new allocated key
+ cacheKeys.remove(key);
releaseKey(cacheKey);
}
return success;
@@ -389,12 +386,12 @@ bool QPMCache::replace(const QPixmapCache::Key &key, const QPixmap &pixmap, int
bool QPMCache::remove(const QString &key)
{
- QPixmapCache::Key cacheKey = cacheKeys.value(key);
+ auto cacheKey = cacheKeys.constFind(key);
//The key was not in the cache
- if (!cacheKey.d)
+ if (cacheKey == cacheKeys.constEnd())
return false;
- cacheKeys.remove(key);
- return QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(cacheKey);
+ cacheKeys.erase(cacheKey);
+ return QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(cacheKey.value());
}
bool QPMCache::remove(const QPixmapCache::Key &key)