summaryrefslogtreecommitdiffstats
path: root/src/widgets/graphicsview
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas@hanssen.name>2013-07-30 18:08:10 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-05 20:15:53 +0200
commit8fce4e97ba8479a24bff167ce72ed43223076905 (patch)
treef1704d41e3ec163434c57931c17e75a7591d75eb /src/widgets/graphicsview
parent12571cc095ce1d789f27f94bfc530efb32d9d1b3 (diff)
Fix double transform for items ignoring parent transformations.
Previously, the topmost untransformable's scene transform, which includes the item's position and local transformation, was used to determine the item's anchoring position. This position was then passed on to be multiplied by the item's transform again. This works fine for toplevel untransformable items that don't have any transform set at all, but those who do would have their transforms applied twice - one to determine the anchoring position, and again to transform the item itself. Since only translation transformations can affect the first operation (the anchoring pos), this bug only applies to items that set ItemIgnoresTransformations and use a local transform that includes translation. Task-number: QTBUG-21618 Change-Id: I772d52d59dfd9f242d0140632a87e9c68dfe0ea1 Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
Diffstat (limited to 'src/widgets/graphicsview')
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 1c15905ff0..db2b71f508 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -4199,9 +4199,14 @@ QTransform QGraphicsItem::deviceTransform(const QTransform &viewportTransform) c
return QTransform();
}
- // First translate the base untransformable item.
- untransformedAncestor->d_ptr->ensureSceneTransform();
- QPointF mappedPoint = (untransformedAncestor->d_ptr->sceneTransform * viewportTransform).map(QPointF(0, 0));
+ // Determine the inherited origin. Find the parent of the topmost untransformable.
+ // Use its scene transform to map the position of the untransformable. Then use
+ // that viewport position as the anchoring point for the untransformable subtree.
+ QGraphicsItem *parentOfUntransformedAncestor = untransformedAncestor->parentItem();
+ QTransform inheritedMatrix;
+ if (parentOfUntransformedAncestor)
+ inheritedMatrix = parentOfUntransformedAncestor->sceneTransform();
+ QPointF mappedPoint = (inheritedMatrix * viewportTransform).map(untransformedAncestor->pos());
// COMBINE
QTransform matrix = QTransform::fromTranslate(mappedPoint.x(), mappedPoint.y());