From c57681bc376d1d912d23b044c48932fa8f7816d7 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Thu, 20 Dec 2018 00:10:50 +0100 Subject: [PATCH] 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 --- src/quick/util/qquickpixmapcache.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index c1bf2160da..dc8bed8125 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -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