diff options
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 5 | ||||
-rw-r--r-- | tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 29 |
2 files changed, 32 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 36a24db..921e121 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4984,14 +4984,15 @@ void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, b return; } - bool hasNoContents = item->d_ptr->flags & QGraphicsItem::ItemHasNoContents - && !item->d_ptr->graphicsEffect; + bool hasNoContents = item->d_ptr->flags & QGraphicsItem::ItemHasNoContents; if (!hasNoContents) { item->d_ptr->dirty = 1; if (fullItemUpdate) item->d_ptr->fullUpdatePending = 1; else if (!item->d_ptr->fullUpdatePending) item->d_ptr->needsRepaint |= rect; + } else if (item->d_ptr->graphicsEffect) { + invalidateChildren = true; } if (invalidateChildren) { diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index fa6a5ec..e1bfb79 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -76,6 +76,7 @@ private slots: void dropShadowClipping(); void childrenVisibilityShouldInvalidateCache(); void prepareGeometryChangeInvalidateCache(); + void itemHasNoContents(); }; void tst_QGraphicsEffect::initTestCase() @@ -675,6 +676,34 @@ void tst_QGraphicsEffect::prepareGeometryChangeInvalidateCache() QCOMPARE(item->nbPaint, 0); } +void tst_QGraphicsEffect::itemHasNoContents() +{ + QGraphicsRectItem *parent = new QGraphicsRectItem; + parent->setFlag(QGraphicsItem::ItemHasNoContents); + + MyGraphicsItem *child = new MyGraphicsItem; + child->setParentItem(parent); + child->resize(200, 200); + + QGraphicsScene scene; + scene.addItem(parent); + + QGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(child->nbPaint, 1); + + CustomEffect *effect = new CustomEffect; + parent->setGraphicsEffect(effect); + QTRY_COMPARE(effect->numRepaints, 1); + + for (int i = 0; i < 3; ++i) { + effect->reset(); + effect->update(); + QTRY_COMPARE(effect->numRepaints, 1); + } +} + QTEST_MAIN(tst_QGraphicsEffect) #include "tst_qgraphicseffect.moc" |