diff options
author | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2009-06-05 13:46:29 +0200 |
---|---|---|
committer | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2009-06-12 11:27:31 +0200 |
commit | 8d1f218f6b11cff798bcd0b3123a2fe38c4a4142 (patch) | |
tree | f891e89e3bb50a174574a5a3c6c632bc5a32e496 | |
parent | d2b1c2d1c9cf5375d7e1cb7e1b08420eb00bada8 (diff) | |
download | qt4-tools-8d1f218f6b11cff798bcd0b3123a2fe38c4a4142.tar.gz |
QGraphicsItem::setOpacity(0.0) does not trigger an update of child items
Forwarding the ignoreOpacity flag to children in QGraphicsItemPrivate::fullUpdateHelper.
This is a complementary fix to task 252913, partly fixed in commit 2e3a5ea44...
Reviewed-by: bnilsen
BT: yes
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 51 |
2 files changed, 51 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index e8ace6575f..7b1967bfd2 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3721,7 +3721,7 @@ void QGraphicsItemPrivate::fullUpdateHelper(bool childrenOnly, bool maybeDirtyCl } } foreach (QGraphicsItem *child, children) - child->d_ptr->fullUpdateHelper(false, maybeDirtyClipPath); + child->d_ptr->fullUpdateHelper(false, maybeDirtyClipPath, ignoreOpacity); dirtyChildren = 1; } diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 34a6ab18d0..30174079d8 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -207,6 +207,7 @@ private slots: void opacity_data(); void opacity(); void opacity2(); + void opacityZeroUpdates(); void itemStacksBehindParent(); void nestedClipping(); void nestedClippingTransforms(); @@ -5498,7 +5499,7 @@ void tst_QGraphicsItem::itemTransform_unrelated() QCOMPARE(stranger1->itemTransform(stranger2).map(QPointF(10, 10)), QPointF(10, 10)); QCOMPARE(stranger2->itemTransform(stranger1).map(QPointF(10, 10)), QPointF(10, 10)); } - + void tst_QGraphicsItem::opacity_data() { QTest::addColumn<qreal>("p_opacity"); @@ -5693,6 +5694,54 @@ void tst_QGraphicsItem::opacity2() QCOMPARE(grandChild->repaints, 0); } +void tst_QGraphicsItem::opacityZeroUpdates() +{ + EventTester *parent = new EventTester; + EventTester *child = new EventTester(parent); + + child->setPos(10, 10); + + QGraphicsScene scene; + scene.addItem(parent); + + class MyGraphicsView : public QGraphicsView + { public: + int repaints; + QRegion paintedRegion; + MyGraphicsView(QGraphicsScene *scene) : QGraphicsView(scene), repaints(0) {} + void paintEvent(QPaintEvent *e) + { + ++repaints; + paintedRegion += e->region(); + QGraphicsView::paintEvent(e); + } + void reset() { repaints = 0; paintedRegion = QRegion(); } + }; + + MyGraphicsView view(&scene); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(250); + + view.reset(); + parent->setOpacity(0.0); + + QTest::qWait(200); + + // transforming items bounding rect to view coordinates + const QRect childDeviceBoundingRect = child->deviceTransform(view.viewportTransform()) + .mapRect(child->boundingRect()).toRect(); + const QRect parentDeviceBoundingRect = parent->deviceTransform(view.viewportTransform()) + .mapRect(parent->boundingRect()).toRect(); + + QRegion expectedRegion = parentDeviceBoundingRect.adjusted(-2, -2, 2, 2); + expectedRegion += childDeviceBoundingRect.adjusted(-2, -2, 2, 2); + + QCOMPARE(view.paintedRegion, expectedRegion); +} + void tst_QGraphicsItem::itemStacksBehindParent() { QGraphicsRectItem *parent1 = new QGraphicsRectItem(QRectF(0, 0, 100, 50)); |