diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2010-01-22 11:46:32 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2010-01-22 17:45:58 (GMT) |
commit | 3e51b6c872e86a5e68a8e59770fc1bc32b84da0c (patch) | |
tree | 3f39af6838ee89b8d726e5e718660cbd34af3e43 /tests/auto/qgraphicswidget | |
parent | 6968a9b9281ef191c566a8e44447fc299cbdd4b7 (diff) | |
download | Qt-3e51b6c872e86a5e68a8e59770fc1bc32b84da0c.zip Qt-3e51b6c872e86a5e68a8e59770fc1bc32b84da0c.tar.gz Qt-3e51b6c872e86a5e68a8e59770fc1bc32b84da0c.tar.bz2 |
QGraphicsWidget is painted twice on the inital show.
Problem occured when doing something in the polishEvent() which
eventually ended up as an update(). The problem was that in
QGraphicsScene::addItem we scheduled a polish event after scheduling
an update, resulting in update requests being processed before polish
requests.
Auto-test included.
Task-number: QTBUG-6956
Reviewed-by: alexis
Diffstat (limited to 'tests/auto/qgraphicswidget')
-rw-r--r-- | tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 909ea54..d3132fe 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -163,6 +163,7 @@ private slots: void addChildInpolishEvent(); void polishEvent(); void polishEvent2(); + void initialShow(); // Task fixes void task236127_bspTreeIndexFails(); @@ -2856,6 +2857,30 @@ void tst_QGraphicsWidget::polishEvent2() QVERIFY(widget->events.contains(QEvent::Polish)); } +void tst_QGraphicsWidget::initialShow() +{ + class MyGraphicsWidget : public QGraphicsWidget + { public: + MyGraphicsWidget() : repaints(0) {} + int repaints; + void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget*) { ++repaints; } + void polishEvent() { update(); } + }; + + QGraphicsScene scene; + MyGraphicsWidget *widget = new MyGraphicsWidget; + + QGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + + QTest::qWait(100); + scene.addItem(widget); + QTest::qWait(100); + + QCOMPARE(widget->repaints, 1); +} + void tst_QGraphicsWidget::QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems() { QGraphicsScene scene; |