From 548155fec3a8b575215625d4fd767e63c20f6b84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Mon, 13 Sep 2010 14:23:04 +0200 Subject: Assertion calledEmitUpdated fails in QGraphicsScene. Problem was that the 'updateAll' boolean was reset to 'false' when it really should have been unchanged. This happened when rendering the scene from outside the view's paint event (i.e. from QGraphicsView/Scene::render). We only want to reset 'updateAll' when triggering drawItems() from QGraphicsView::paintEvent, i.e. when the 'view' pointer != 0. Broke after commit: dda8a57c. Auto test included. Task-number: QT-3674 --- src/gui/graphicsview/qgraphicsscene.cpp | 2 +- tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 539685a..36a24db 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5270,7 +5270,6 @@ void QGraphicsScene::drawItems(QPainter *painter, if (!d->unpolishedItems.isEmpty()) d->_q_polishItems(); - d->updateAll = false; QTransform viewTransform = painter->worldTransform(); Q_UNUSED(options); @@ -5279,6 +5278,7 @@ void QGraphicsScene::drawItems(QPainter *painter, QRegion *expose = 0; const quint32 oldRectAdjust = d->rectAdjust; if (view) { + d->updateAll = false; expose = &view->d_func()->exposedRegion; if (view->d_func()->optimizationFlags & QGraphicsView::DontAdjustForAntialiasing) d->rectAdjust = 1; diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index c145623..b8e729e 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -287,6 +287,7 @@ private slots: void taskQTBUG_5904_crashWithDeviceCoordinateCache(); void taskQT657_paintIntoCacheWithTransparentParts(); void taskQTBUG_7863_paintIntoCacheWithTransparentParts(); + void taskQT_3674_doNotCrash(); }; void tst_QGraphicsScene::initTestCase() @@ -4565,6 +4566,25 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() } } +void tst_QGraphicsScene::taskQT_3674_doNotCrash() +{ + QGraphicsScene scene; + + QGraphicsView view(&scene); + view.resize(200, 200); + + QPixmap pixmap(view.size()); + QPainter painter(&pixmap); + view.render(&painter); + painter.end(); + + scene.addItem(new QGraphicsWidget); + scene.setBackgroundBrush(Qt::green); + + QApplication::processEvents(); + QApplication::processEvents(); +} + void tst_QGraphicsScene::zeroScale() { //should not crash -- cgit v0.12