From ee956824db495c12f51dd0d864e009f0417464d5 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 7 Jul 2023 10:38:38 +0200 Subject: [PATCH] QPixmapCache: assert that the key is invalid if we failed to insert QCache::insert on failure destroys the QPixmapCacheEntry, which calls releaseKey(), which invalidates the key. That's hard to follow, so add an assert to make it more explicit and prevent future errors. Pick-to: 6.6 Change-Id: I9c062ef5a6e34c783c064330c914ce4f9a3f9984 Reviewed-by: Marc Mutz Reviewed-by: Edward Welbourne --- src/gui/image/qpixmapcache.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index 4637b38dd79..45c9743f937 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -317,6 +317,7 @@ QPixmapCache::Key QPMCache::insert(const QPixmap &pixmap, int cost) { QPixmapCache::Key cacheKey = createKey(); // invalidated by ~QPixmapCacheEntry on failed insert bool success = QCache::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); + Q_ASSERT(success || !cacheKey.isValid()); if (success) { if (!theid) { theid = startTimer(flush_time);