diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-12-03 14:33:42 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-12-04 16:56:47 +0000 |
commit | 909e6a009c968042f5295358737c9d2d84fcc0ba (patch) | |
tree | 40900f5a8041809ec41e55acf46a8fdaeb7a8e39 | |
parent | 6b1dc2641e43f3e35ef91fb2d1301be236de9f95 (diff) |
Clean up QGraphicsItemCache::purge()
The old code assigned an empty QPoint to elements contained
by value in a QHash that was cleared out in the very next
step.
That makes no sense, because the operations in the loop cannot
possibly cause a re-entrancy into QGraphicsItemCache, which
would be the only explanation for modifying the state of a
death-row object.
While at it, replace the use of the highly inefficient
(and no longer needed) QMutableHashIterator with C++11
range-for, taking care to iterate over a const reference to
avoid detaches.
Change-Id: Ie3eba0f954644a27932666bc9e97f1ca8f36a578
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
-rw-r--r-- | src/widgets/graphicsview/qgraphicsitem.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 5f5c402a4a..54a98b4d2d 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -1373,12 +1373,9 @@ void QGraphicsItemCache::purge() { QPixmapCache::remove(key); key = QPixmapCache::Key(); - QMutableHashIterator<QPaintDevice *, DeviceData> it(deviceData); - while (it.hasNext()) { - DeviceData &data = it.next().value(); + const auto &constDeviceData = deviceData; // avoid detach + for (const auto &data : constDeviceData) QPixmapCache::remove(data.key); - data.cacheIndent = QPoint(); - } deviceData.clear(); allExposed = true; exposed.clear(); |