diff options
author | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-04-15 08:23:08 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-04-15 08:38:59 (GMT) |
commit | 7a0f9ae94ca7a47dc285431d31f6839c07870194 (patch) | |
tree | ac46d83f38015a708237574db351db2c2af9380f /src/gui | |
parent | b33ebce3de3efd98a45c8ca0a349f78aac09c875 (diff) | |
download | Qt-7a0f9ae94ca7a47dc285431d31f6839c07870194.zip Qt-7a0f9ae94ca7a47dc285431d31f6839c07870194.tar.gz Qt-7a0f9ae94ca7a47dc285431d31f6839c07870194.tar.bz2 |
BT: Fix a regression to 4.4 in Graphics View's handling of child clippers
Regression caused by optimizations in QGraphicsItem and QGraphicsScene.
The changes in QGraphicsItem fix bugs in QGraphicsItem::mapToParent
functions, which did the translation before applying the transformation,
instead of the other way (transform, then translate). This bug caused
almost all mapToParent and mapRectToParent functions to behave wrongly.
Unfortunately the new helper functions in QGraphicsScene for discovering
items made use of these functions, which introduced a regression. Fixing
these functions also fixes item discovery.
The other part of this change fixes a regression caused by c1909321,
which luckily happened after 4.5.0 and never saw the light of day. The
fix is to also invalidate the cached clip path even if there is no scene,
which is necessary if you build your scene graph outside the scene, and
finish off by adding the root item to the scene.
Task-number: 250680
Reviewed-by: Alexis
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index b520a3f..e6bcaa6 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -4223,9 +4223,9 @@ QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QRectF &rect */ QPolygonF QGraphicsItem::mapToParent(const QRectF &rect) const { - if (!d_ptr->hasTransform) - return QPolygonF(rect.translated(d_ptr->pos)); - return transform().map(rect.translated(d_ptr->pos)); + QPolygonF p = !d_ptr->hasTransform ? rect : transform().map(rect); + p.translate(d_ptr->pos); + return p; } /*! @@ -4292,8 +4292,8 @@ QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, const QRectF &rec */ QRectF QGraphicsItem::mapRectToParent(const QRectF &rect) const { - QRectF r = rect.translated(d_ptr->pos.x(), d_ptr->pos.y()); - return !d_ptr->hasTransform ? r : transform().mapRect(r); + QRectF r = !d_ptr->hasTransform ? rect : transform().mapRect(rect); + return r.translated(d_ptr->pos); } /*! @@ -4424,9 +4424,9 @@ QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPolygonF &p */ QPolygonF QGraphicsItem::mapToParent(const QPolygonF &polygon) const { - QPolygonF p = polygon; + QPolygonF p = !d_ptr->hasTransform ? polygon : transform().map(polygon); p.translate(d_ptr->pos); - return d_ptr->hasTransform ? transform().map(p) : p; + return p; } /*! @@ -4468,7 +4468,10 @@ QPainterPath QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPainterP */ QPainterPath QGraphicsItem::mapToParent(const QPainterPath &path) const { - return d_ptr->parent ? itemTransform(d_ptr->parent).map(path) : mapToScene(path); + QTransform x = QTransform::fromTranslate(d_ptr->pos.x(), d_ptr->pos.y()); + if (d_ptr->hasTransform) + x = transform() * x; + return x.map(path); } /*! @@ -5697,12 +5700,11 @@ void QGraphicsItem::removeFromIndex() */ void QGraphicsItem::prepareGeometryChange() { - if (!d_ptr->scene) - return; - - d_ptr->updateHelper(QRectF(), false, /*maybeDirtyClipPath=*/!d_ptr->inSetPosHelper); - QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func(); - scenePrivate->removeFromIndex(this); + if (d_ptr->scene) { + d_ptr->updateHelper(QRectF(), false, /*maybeDirtyClipPath=*/!d_ptr->inSetPosHelper); + QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func(); + scenePrivate->removeFromIndex(this); + } if (d_ptr->inSetPosHelper) return; |