summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qiconloader.cpp4
-rw-r--r--src/gui/image/qpixmapcache.cpp19
2 files changed, 9 insertions, 14 deletions
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index eda9d6f24e..17d77a07b5 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -383,13 +383,11 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
// Used to protect against potential recursions
visited << themeName;
- QIconTheme theme = themeList.value(themeName);
+ QIconTheme &theme = themeList[themeName];
if (!theme.isValid()) {
theme = QIconTheme(themeName);
if (!theme.isValid())
theme = QIconTheme(fallbackTheme());
-
- themeList.insert(themeName, theme);
}
const QStringList contentDirs = theme.contentDirs();
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)