summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-10-09 08:19:33 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2009-10-09 08:27:12 (GMT)
commitb8eb2784a1c1a9812d09fca7c8722624f12dbd1c (patch)
treed31a997161f1f8582a09c2fc8a2833194018f1de
parentfc3dfc20d487cb4fd2f93bd9fa36eef85a7467a3 (diff)
downloadQt-b8eb2784a1c1a9812d09fca7c8722624f12dbd1c.zip
Qt-b8eb2784a1c1a9812d09fca7c8722624f12dbd1c.tar.gz
Qt-b8eb2784a1c1a9812d09fca7c8722624f12dbd1c.tar.bz2
Add a test case for task QTBUG-4439.
Commit fc3dfc20d487cb4fd2f93bd9fa36eef85a7467a3 fixes the problem. The unpolished items list was modified in between the iteration which means that invokeMethod was never recall if you add an item inside the polishEvent handler. The invokeMethod is called in addItem only when the list is empty right before we add the item in the list. Task-number:QTBUG-4439 Reviewed-by:TrustMe
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index 26021e0..6b5ad09 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -159,6 +159,7 @@ private slots:
void ensureClipping();
void widgetSendsGeometryChanges();
void respectHFW();
+ void addChildInpolishEvent();
// Task fixes
void task236127_bspTreeIndexFails();
@@ -2716,6 +2717,58 @@ void tst_QGraphicsWidget::respectHFW()
#endif
}
+class PolishWidget : public QGraphicsWidget
+{
+public:
+
+ PolishWidget(Qt::GlobalColor color, QGraphicsItem *parent=0) :
+ QGraphicsWidget(parent), mColor(color)
+ {
+ }
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+ {
+ painter->setBrush(QBrush(mColor));
+ painter->drawRect(boundingRect());
+ }
+
+ void polishEvent()
+ {
+ if (!parentWidget()) {
+ //We add a child in the polish event for the parent
+ PolishWidget *childWidget = new PolishWidget(Qt::black, this);
+ childWidget->setGeometry(QRectF(10,10,30,30));
+ }
+
+ QGraphicsWidget::polishEvent();
+ mColor = Qt::red;
+ update();
+ numberOfPolish++;
+ }
+
+ static int numberOfPolish;
+
+private:
+ Qt::GlobalColor mColor;
+};
+
+int PolishWidget::numberOfPolish = 0;
+
+void tst_QGraphicsWidget::addChildInpolishEvent()
+{
+ QGraphicsScene scene;
+
+ PolishWidget *parentWidget = new PolishWidget(Qt::white);
+ scene.addItem(parentWidget);
+
+ QGraphicsView view(&scene);
+ view.resize(200, 200);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ QCOMPARE(PolishWidget::numberOfPolish, 2);
+}
+
+
QTEST_MAIN(tst_QGraphicsWidget)
#include "tst_qgraphicswidget.moc"