From 1d09b0d1b28eaea17069f7359956640f31ea79c6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 28 Jun 2016 13:05:10 +0200 Subject: [PATCH] QGraphicsScene::update(): Keep the list of updatedRects() unique Otherwise, the rects will pile up when the item is not part of a view. Task-number: QTBUG-54275 Change-Id: I29c989e25ce0ca1ac0b87d0388a476ef1acd9cfd Reviewed-by: Allan Sandfeld Jensen --- src/widgets/graphicsview/qgraphicsscene.cpp | 3 ++- .../graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 7cc694a613..37af4ecda0 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -3215,7 +3215,8 @@ void QGraphicsScene::update(const QRectF &rect) view->d_func()->updateRectF(rect); } } else { - d->updatedRects << rect; + if (!d->updatedRects.contains(rect)) + d->updatedRects << rect; } } diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 1130a47260..27eac03880 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -2206,10 +2206,11 @@ void tst_QGraphicsItem::setMatrix() QCOMPARE(spy.count(), 3); QList rlist = qvariant_cast >(spy.last().at(0)); - QCOMPARE(rlist.size(), 3); - QCOMPARE(rlist.at(0), rotatedRect); // From item.setMatrix() (clearing rotated rect) - QCOMPARE(rlist.at(1), rotatedRect); // From scene.update() (updating scene rect) - QCOMPARE(rlist.at(2), unrotatedRect); // From post-update (update current state) + QCOMPARE(rlist.size(), 2); + // From item.setMatrix() (clearing rotated rect), from scene.update() (updating scene rect), + // squashed into one + QCOMPARE(rlist.at(0), rotatedRect); + QCOMPARE(rlist.at(1), unrotatedRect); // From post-update (update current state) } static QList _paintedItems;