diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2009-09-29 09:18:41 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2009-09-29 09:18:41 (GMT) |
commit | f4c9c027643d204648bf50307751964ef8572862 (patch) | |
tree | 7824fa100b31acb0281cf4abb233fbac8e5542b5 | |
parent | aa65b608b96f0b41e96093e6eb26ccc0f301afc9 (diff) | |
parent | e9d63b7824e9105074dee9ad624582e5894d9c8b (diff) | |
download | Qt-f4c9c027643d204648bf50307751964ef8572862.zip Qt-f4c9c027643d204648bf50307751964ef8572862.tar.gz Qt-f4c9c027643d204648bf50307751964ef8572862.tar.bz2 |
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt into 4.5
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 26 | ||||
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 31 |
2 files changed, 41 insertions, 16 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 5799fe7..4f77aa8 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3975,26 +3975,20 @@ void QGraphicsItem::update(const QRectF &rect) return; if (CacheMode(d_ptr->cacheMode) != NoCache) { + // Invalidate cache. QGraphicsItemCache *cache = d_ptr->extraItemCache(); - if (d_ptr->discardUpdateRequest(/* ignoreVisibleBit = */ false, - /* ignoreClipping = */ false, - /* ignoreDirtyBit = */ true)) { - return; + if (!cache->allExposed) { + if (rect.isNull()) { + cache->allExposed = true; + cache->exposed.clear(); + } else { + cache->exposed.append(rect); + } } + } - // Invalidate cache. - if (rect.isNull()) { - cache->allExposed = true; - cache->exposed.clear(); - } else { - cache->exposed.append(rect); - } - // Only invalidate cache; item is already dirty. - if (d_ptr->dirty) - return; - } else if (d_ptr->discardUpdateRequest()) { + if (d_ptr->discardUpdateRequest()) return; - } // Effectively the same as updateHelper(rect); if (rect.isNull()) diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 391ccf8..55e9b34 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -56,6 +56,7 @@ #include <QPainter> #include <QScrollBar> #include <QVBoxLayout> +#include "../../shared/util.h" //TESTED_CLASS= //TESTED_FILES= @@ -230,6 +231,7 @@ private slots: void task240400_clickOnTextItem(); void task243707_addChildBeforeParent(); void task197802_childrenVisibility(); + void QTBUG_4233_updateCachedWithSceneRect(); }; void tst_QGraphicsItem::init() @@ -6454,5 +6456,34 @@ void tst_QGraphicsItem::deviceTransform() QCOMPARE(rect3->deviceTransform(deviceX).map(QPointF(50, 50)), mapResult3); } +void tst_QGraphicsItem::QTBUG_4233_updateCachedWithSceneRect() +{ + EventTester *tester = new EventTester; + tester->setCacheMode(QGraphicsItem::ItemCoordinateCache); + + QGraphicsScene scene; + scene.addItem(tester); + scene.setSceneRect(-100, -100, 200, 200); // contains the tester item + + QGraphicsView view(&scene); + view.show(); + QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view); + + QCOMPARE(tester->repaints, 1); + + scene.update(); // triggers "updateAll" optimization + qApp->processEvents(); + qApp->processEvents(); // in 4.6 only one processEvents is necessary + + QCOMPARE(tester->repaints, 1); + + scene.update(); // triggers "updateAll" optimization + tester->update(); + qApp->processEvents(); + qApp->processEvents(); // in 4.6 only one processEvents is necessary + + QCOMPARE(tester->repaints, 2); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" |