diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-06-04 17:32:19 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-06-09 07:34:33 (GMT) |
commit | 9def469f9f83087fab9cb65c0200f2e6059519ad (patch) | |
tree | 444146f372ae7a513b82acd7aa7ae181ebdba6ba /src | |
parent | ed0b10aff5d0afb7e8165dbf9b14f30cfd73e3ff (diff) | |
download | Qt-9def469f9f83087fab9cb65c0200f2e6059519ad.zip Qt-9def469f9f83087fab9cb65c0200f2e6059519ad.tar.gz Qt-9def469f9f83087fab9cb65c0200f2e6059519ad.tar.bz2 |
Compatibility fix for QGraphicsScene::changed signal.
Makes tst_QGraphicsScene::changedSignal and
tst_QGraphicsItem::setMatrix happy.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 17 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 8 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 807ee06..a2d885b 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -5979,10 +5979,21 @@ void QGraphicsItem::prepareGeometryChange() if (d_ptr->scene) { d_ptr->geometryChanged = 1; d_ptr->paintedViewBoundingRectsNeedRepaint = 1; - d_ptr->scene->d_func()->markDirty(this, QRectF(), - /*invalidateChildren=*/true, - /*maybeDirtyClipPath=*/!d_ptr->inSetPosHelper); + QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func(); + scenePrivate->markDirty(this, QRectF(), + /*invalidateChildren=*/true, + /*maybeDirtyClipPath=*/!d_ptr->inSetPosHelper); + + // For compatibility reasons, we have to update the item's old geometry + // if someone is connected to the changed signal or the scene has no views. + // Note that this has to be done *after* markDirty to ensure that + // _q_processDirtyItems is called before _q_emitUpdated. + if ((scenePrivate->connectedSignals & scenePrivate->changedSignalMask) + || scenePrivate->views.isEmpty()) { + d_ptr->scene->update(sceneTransform().mapRect(boundingRect())); + } + scenePrivate->removeFromIndex(this); } diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 4578bd4..c7a41d6 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -682,6 +682,7 @@ void QGraphicsScenePrivate::_q_processDirtyItems() if (updateAll) return; + const bool wasPendingSceneUpdate = calledEmitUpdated; const QRectF oldGrowingItemsBoundingRect = growingItemsBoundingRect; processDirtyItemsRecursive(0); if (!hasSceneRect && oldGrowingItemsBoundingRect != growingItemsBoundingRect) @@ -689,6 +690,13 @@ void QGraphicsScenePrivate::_q_processDirtyItems() for (int i = 0; i < views.size(); ++i) views.at(i)->d_func()->processPendingUpdates(); + + if (!wasPendingSceneUpdate && calledEmitUpdated) { + // We did a compatibility QGraphicsScene::update in processDirtyItemsRecursive + // and we cannot wait for the control to reach the eventloop before the + // changed signal is emitted, so we emit it now. + _q_emitUpdated(); + } } /*! |