diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-10-23 11:17:06 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-10-23 13:03:13 (GMT) |
commit | 72fb0f2637db401efd178b9d4139fc2b6ef59112 (patch) | |
tree | b9c2dcbd3208e7569ad813646474d1d39df5f2fa /src | |
parent | a1301736c3fdc25bdf6f35bf67747804adb83ac3 (diff) | |
download | Qt-72fb0f2637db401efd178b9d4139fc2b6ef59112.zip Qt-72fb0f2637db401efd178b9d4139fc2b6ef59112.tar.gz Qt-72fb0f2637db401efd178b9d4139fc2b6ef59112.tar.bz2 |
Wrong worldTransform() on the painter in QGraphicsScene::drawForeground.
The painter's worldTransform() is updated for each item we draw, and
when the DontSavePainterState optimization flag is set, this change is
not protected by save() and restore(). After all the items are drawn, it
means the painter is left with the last drawn item's transform. We
therefore have to make sure it is reset back to whatever it was before
the items were drawn.
Auto-test included.
Task-number: QTBUG-4973
Reviewed-by: alexis
Reviewed-by: andreas
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/graphicsview/qgraphicsview.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 32747cc..49348de 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -3306,6 +3306,14 @@ void QGraphicsView::paintEvent(QPaintEvent *event) if (!(d->optimizationFlags & IndirectPainting)) { d->scene->d_func()->drawItems(&painter, viewTransformed ? &viewTransform : 0, &d->exposedRegion, viewport()); + // Make sure the painter's world transform is restored correctly when + // drawing without painter state protection (DontSavePainterState). + // We only change the worldTransform() so there's no need to do a full-blown + // save() and restore(). Also note that we don't have to do this in case of + // IndirectPainting (the else branch), because in that case we always save() + // and restore() in QGraphicsScene::drawItems(). + if (!d->scene->d_func()->painterStateProtection) + painter.setWorldTransform(viewTransform); } else { // Find all exposed items bool allItems = false; |