diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index 76fba1eb93..6c62bae69e 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -352,13 +352,8 @@ QPixmapCache::Key QPMCache::insert(const QPixmap &pixmap, int cost) bool QPMCache::remove(const QString &key) { - auto cacheKey = cacheKeys.constFind(key); - //The key was not in the cache - if (cacheKey == cacheKeys.constEnd()) - return false; - const bool result = QCache::remove(cacheKey.value()); - cacheKeys.erase(cacheKey); - return result; + const auto cacheKey = cacheKeys.take(key); + return cacheKey.isValid() && remove(cacheKey); } bool QPMCache::remove(const QPixmapCache::Key &key)