diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-07-07 10:38:38 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-07-10 14:11:30 +0200 |
commit | ee956824db495c12f51dd0d864e009f0417464d5 (patch) | |
tree | 19e85f44309aa1db15335cbeae8c40d5c93eba68 | |
parent | 6ee9adc43aef1da47fcd9fee13140af81549e875 (diff) |
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 <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
-rw-r--r-- | src/gui/image/qpixmapcache.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index 4637b38dd7..45c9743f93 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<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); + Q_ASSERT(success || !cacheKey.isValid()); if (success) { if (!theid) { theid = startTimer(flush_time); |