summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h7
-rw-r--r--tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp28
2 files changed, 35 insertions, 0 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index ea04e0be4d..e737773157 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -769,6 +769,13 @@ inline bool QGraphicsItemPrivate::insertionOrder(QGraphicsItem *a, QGraphicsItem
inline void QGraphicsItemPrivate::markParentDirty(bool updateBoundingRect)
{
QGraphicsItemPrivate *parentp = this;
+#ifndef QT_NO_GRAPHICSEFFECT
+ if (updateBoundingRect && parentp->graphicsEffect && !parentp->inSetPosHelper) {
+ parentp->notifyInvalidated = 1;
+ static_cast<QGraphicsItemEffectSourcePrivate *>(parentp->graphicsEffect->d_func()
+ ->source->d_func())->invalidateCache();
+ }
+#endif
while (parentp->parent) {
parentp = parentp->parent->d_ptr.data();
parentp->dirtyChildren = 1;
diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
index dbd4a233f1..5dc0c9dd67 100644
--- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -75,6 +75,7 @@ private slots:
void inheritOpacity();
void dropShadowClipping();
void childrenVisibilityShouldInvalidateCache();
+ void prepareGeometryChangeInvalidateCache();
};
void tst_QGraphicsEffect::initTestCase()
@@ -647,6 +648,33 @@ void tst_QGraphicsEffect::childrenVisibilityShouldInvalidateCache()
QCOMPARE(parent.nbPaint, 3);
}
+void tst_QGraphicsEffect::prepareGeometryChangeInvalidateCache()
+{
+ MyGraphicsItem *item = new MyGraphicsItem;
+ item->resize(200, 200);
+
+ QGraphicsScene scene;
+ scene.addItem(item);
+
+ QGraphicsView view(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(item->nbPaint, 1);
+
+ item->nbPaint = 0;
+ item->setGraphicsEffect(new QGraphicsDropShadowEffect);
+ QTRY_COMPARE(item->nbPaint, 1);
+
+ item->nbPaint = 0;
+ item->resize(300, 300);
+ QTRY_COMPARE(item->nbPaint, 1);
+
+ item->nbPaint = 0;
+ item->setPos(item->pos() + QPointF(10, 10));
+ QTest::qWait(50);
+ QCOMPARE(item->nbPaint, 0);
+}
+
QTEST_MAIN(tst_QGraphicsEffect)
#include "tst_qgraphicseffect.moc"