summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
diff options
context:
space:
mode:
authorEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-07-23 22:59:05 (GMT)
committerEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-08-06 22:47:31 (GMT)
commitf48d5dd7554edef5ac3fa11ebd86eaa52a8e23b6 (patch)
tree133df0421d5c5cdfd332bcdec99917a6582c0dda /src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
parentaa05ec20ee0961f129eb66527892360c17dc3a18 (diff)
downloadQt-f48d5dd7554edef5ac3fa11ebd86eaa52a8e23b6.zip
Qt-f48d5dd7554edef5ac3fa11ebd86eaa52a8e23b6.tar.gz
Qt-f48d5dd7554edef5ac3fa11ebd86eaa52a8e23b6.tar.bz2
QGraphicsAnchorLayout: Fix center anchor deletion logic
We were missing a call to "removeCenterAnchors" in the "removeAnchors" method. To solve that, and also reduce the number of useless calls to that method, this commit: 1) Calls it only from "removeInternalVertex" 2) Does some preliminary testing before calling it 3) Replace the former test inside "removeCenterAnchors" by a Q_ASSERT It also adds other Q_ASSERTs to protect us from regression bugs. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
Diffstat (limited to 'src/gui/graphicsview/qgraphicsanchorlayout_p.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index 7516c06..afe60a1 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -456,6 +456,9 @@ void QGraphicsAnchorLayoutPrivate::deleteLayoutEdges()
{
Q_Q(QGraphicsAnchorLayout);
+ Q_ASSERT(internalVertex(q, QGraphicsAnchorLayout::HCenter) == NULL);
+ Q_ASSERT(internalVertex(q, QGraphicsAnchorLayout::VCenter) == NULL);
+
removeAnchor(q, QGraphicsAnchorLayout::Left, q, QGraphicsAnchorLayout::Right);
removeAnchor(q, QGraphicsAnchorLayout::Top, q, QGraphicsAnchorLayout::Bottom);
}
@@ -568,11 +571,6 @@ void QGraphicsAnchorLayoutPrivate::removeCenterAnchors(
return;
}
- // Check if vertex is used by other than the internal anchors
- AnchorVertex *center = internalVertex(item, centerEdge);
- if (graph[orientation].adjacentVertices(center).count() > 2)
- return;
-
// Orientation code
QGraphicsAnchorLayout::Edge firstEdge;
QGraphicsAnchorLayout::Edge lastEdge;
@@ -586,8 +584,10 @@ void QGraphicsAnchorLayoutPrivate::removeCenterAnchors(
}
AnchorVertex *first = internalVertex(item, firstEdge);
+ AnchorVertex *center = internalVertex(item, centerEdge);
AnchorVertex *last = internalVertex(item, lastEdge);
- Q_ASSERT(first && last);
+ Q_ASSERT(first && center && last);
+ Q_ASSERT(graph[orientation].adjacentVertices(center).count() == 2);
// Create new anchor
AnchorData *oldData = graph[orientation].edgeData(first, center);
@@ -792,6 +792,12 @@ void QGraphicsAnchorLayoutPrivate::removeInternalVertex(QGraphicsLayoutItem *ite
} else {
// Update reference count
m_vertexList.insert(pair, v);
+
+ if ((v.second == 2) &&
+ ((edge == QGraphicsAnchorLayout::HCenter) ||
+ (edge == QGraphicsAnchorLayout::VCenter))) {
+ removeCenterAnchors(item, edge);
+ }
}
}