summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-11-27 14:14:23 (GMT)
committerEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-11-27 19:18:00 (GMT)
commit5b9d7f05aa369c07c2f498280d8a8b9c81f7aff1 (patch)
tree1d5e499cce9d95a142b136b06a9d47a8aaf21f4a /src/gui/graphicsview
parenta8893f8d17d37ac4a68fc2cf0bdec1c3b124c8f4 (diff)
downloadQt-5b9d7f05aa369c07c2f498280d8a8b9c81f7aff1.zip
Qt-5b9d7f05aa369c07c2f498280d8a8b9c81f7aff1.tar.gz
Qt-5b9d7f05aa369c07c2f498280d8a8b9c81f7aff1.tar.bz2
QGAL: Prevent internal anchors from being exposed by QGAL::anchor()
Adding check to prevent the structural layout anchors as well as those internal to items, from being exposed through the public API. These checks also ensure no QGraphicsAnchor instances will be created for those anchors. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index a6f5992..137806a 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -1652,6 +1652,10 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::getAnchor(QGraphicsLayoutItem *fi
QGraphicsLayoutItem *secondItem,
Qt::AnchorPoint secondEdge)
{
+ // Do not expose internal anchors
+ if (firstItem == secondItem)
+ return 0;
+
const Orientation orientation = edgeOrientation(firstEdge);
AnchorVertex *v1 = internalVertex(firstItem, firstEdge);
AnchorVertex *v2 = internalVertex(secondItem, secondEdge);
@@ -1659,8 +1663,16 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::getAnchor(QGraphicsLayoutItem *fi
QGraphicsAnchor *graphicsAnchor = 0;
AnchorData *data = graph[orientation].edgeData(v1, v2);
- if (data)
- graphicsAnchor = acquireGraphicsAnchor(data);
+ if (data) {
+ // We could use "acquireGraphicsAnchor" here, but to avoid a regression where
+ // an internal anchor was wrongly exposed, I want to ensure no new
+ // QGraphicsAnchor instances are created by this call.
+ // This assumption must hold because anchors are either user-created (and already
+ // have their public object created), or they are internal (and must not reach
+ // this point).
+ Q_ASSERT(data->graphicsAnchor);
+ graphicsAnchor = data->graphicsAnchor;
+ }
return graphicsAnchor;
}