aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@crimson.no>2018-12-20 00:10:50 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2018-12-22 08:23:02 +0000
commitc57681bc376d1d912d23b044c48932fa8f7816d7 (patch)
tree08d723e27215db22422bdc74e1ddde71702bb637 /src
parent75ebbd0b354739150e10da7216b44e2dde2c2b14 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/quick/util/qquickpixmapcache.cpp3
1 files changed, 2 insertions, 1 deletions
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