qquickpixmapcache: Fix invalidation of m_cache while iterating it

Releasing items from the cache modifies m_cache, which we cannot do with
a range-for.

Fixes: QTBUG-65077
Change-Id: I2efcf6a03b03982a54bb1aacff43c55c45782eaa
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Robin Burchell 2018-12-20 00:10:50 +01:00 committed by Simon Hausmann
parent 75ebbd0b35
commit c57681bc37
1 changed files with 2 additions and 1 deletions

View File

@ -1026,7 +1026,8 @@ QQuickPixmapStore::~QQuickPixmapStore()
m_timerId = -2;
// unreference all (leaked) pixmaps
for (auto *pixmap : qAsConst(m_cache)) {
const auto cache = m_cache; // NOTE: intentional copy (QTBUG-65077); releasing items from the cache modifies m_cache.
for (auto *pixmap : cache) {
int currRefCount = pixmap->refCount;
if (currRefCount) {
#ifndef QT_NO_DEBUG