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>
This commit is contained in:
parent
6ee9adc43a
commit
ee956824db
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user