summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>2009-08-12 20:26:52 (GMT)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>2009-08-12 20:35:29 (GMT)
commit376c4fdd263f59f6739d045d441e07a97f5c5122 (patch)
tree6eed9ee6a8120ba2c6aa06e2b99f25b8823e1871
parentae67fcb0538c0f47c77eef0ed39955e33671343e (diff)
downloadQt-376c4fdd263f59f6739d045d441e07a97f5c5122.zip
Qt-376c4fdd263f59f6739d045d441e07a97f5c5122.tar.gz
Qt-376c4fdd263f59f6739d045d441e07a97f5c5122.tar.bz2
Revert "QGraphicsAnchorLayoutPrivate: Avoiding extra loops in getGraphParts"
This reverts commit 9e701f76f7478ea078e58076c91fee0d2ec505b4 and also add a comment explaining why is needed to delay the creation of the nonTrunkVariables to a later moment. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index 9a1cdd0..e3914b8 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -1543,7 +1543,6 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation)
}
QList<QSimplexConstraint *> trunkConstraints;
- QList<QSimplexConstraint *> nonTrunkConstraints;
QSet<QSimplexVariable *> trunkVariables;
trunkVariables += edgeL1;
@@ -1551,7 +1550,6 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation)
trunkVariables += edgeL2;
bool dirty;
- bool hasNonTrunkConstraints = false;
do {
dirty = false;
@@ -1577,9 +1575,15 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation)
it = remainingConstraints.erase(it);
dirty = true;
} else {
- nonTrunkConstraints += c;
- it = remainingConstraints.erase(it);
- hasNonTrunkConstraints = true;
+ // Note that we don't erase the constraint if it's not
+ // a match, since in a next iteration of a do-while we
+ // can pass on it again and it will be a match.
+ //
+ // For example: if trunk share a variable with
+ // remainingConstraints[1] and it shares with
+ // remainingConstraints[0], we need a second iteration
+ // of the do-while loop to match both.
+ ++it;
}
}
} while (dirty);
@@ -1587,8 +1591,15 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation)
QList< QList<QSimplexConstraint *> > result;
result += trunkConstraints;
- if (hasNonTrunkConstraints)
+ if (!remainingConstraints.isEmpty()) {
+ QList<QSimplexConstraint *> nonTrunkConstraints;
+ QLinkedList<QSimplexConstraint *>::iterator it = remainingConstraints.begin();
+ while (it != remainingConstraints.end()) {
+ nonTrunkConstraints += *it;
+ ++it;
+ }
result += nonTrunkConstraints;
+ }
return result;
}