diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2010-01-22 11:46:32 (GMT) |
---|---|---|
committer | Prasanth Ullattil <prasanth.ullattil@nokia.com> | 2010-01-27 15:30:25 (GMT) |
commit | 4bcc8a24129b69efa1217dd033f0af949df0bcb9 (patch) | |
tree | 9a4f5c348dd669be2024e87759ffa0534a3c8608 /tests | |
parent | ef427d48fa684578ecb69e4e1ce2072f12362682 (diff) | |
download | Qt-4bcc8a24129b69efa1217dd033f0af949df0bcb9.zip Qt-4bcc8a24129b69efa1217dd033f0af949df0bcb9.tar.gz Qt-4bcc8a24129b69efa1217dd033f0af949df0bcb9.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')
-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; |