summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicswidget
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-11-12 15:33:42 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-11-13 09:09:49 (GMT)
commit671fb279defa0a97c38c28dded767f58c67f9dac (patch)
tree1dc5793e6e625d38a4d80effaf75046af64c1273 /tests/auto/qgraphicswidget
parent57d05153b3ef2df1f1dd38eb9560d6019e1bcd4a (diff)
downloadQt-671fb279defa0a97c38c28dded767f58c67f9dac.zip
Qt-671fb279defa0a97c38c28dded767f58c67f9dac.tar.gz
Qt-671fb279defa0a97c38c28dded767f58c67f9dac.tar.bz2
Fixes QGraphicsWidget: paint() being called before polish().
The problem is that we request an update() before we schedules a polish event in QGraphicsScene::addItems, which means paint() is being called before polishEvent(). We could try to swap the order in addItems, but that doesn't give us any guarantee that polish is delivered before update (since we have no control over what's happening from outside graphics view). A better solution is to always make sure we don't have unpolished items before we draw. Auto-test included. Task-number: QTBUG-4979 Reviewed-by: Andreas
Diffstat (limited to 'tests/auto/qgraphicswidget')
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index 6b5ad09..829e55c 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -160,6 +160,7 @@ private slots:
void widgetSendsGeometryChanges();
void respectHFW();
void addChildInpolishEvent();
+ void polishEvent();
// Task fixes
void task236127_bspTreeIndexFails();
@@ -2768,6 +2769,32 @@ void tst_QGraphicsWidget::addChildInpolishEvent()
QCOMPARE(PolishWidget::numberOfPolish, 2);
}
+void tst_QGraphicsWidget::polishEvent()
+{
+ class MyGraphicsWidget : public QGraphicsWidget
+ { public:
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
+ { events << QEvent::Paint; }
+ void polishEvent()
+ { events << QEvent::Polish; }
+ QList<QEvent::Type> events;
+ };
+
+ QGraphicsScene scene;
+
+ MyGraphicsWidget *widget = new MyGraphicsWidget;
+ scene.addItem(widget);
+
+ QGraphicsView view(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ // Make sure the item is painted.
+ QTRY_VERIFY(widget->events.contains(QEvent::Paint));
+
+ // Make sure the item got polish before paint.
+ QCOMPARE(widget->events.at(0), QEvent::Polish);
+}
QTEST_MAIN(tst_QGraphicsWidget)
#include "tst_qgraphicswidget.moc"