diff options
author | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-10-26 08:07:39 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-10-26 08:07:39 (GMT) |
commit | b14338cce8cb13003a4943d134502e085f36ab08 (patch) | |
tree | 73cfefc9ea2e5ee23982c0acb3514f7a777e6d77 /tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | |
parent | b2cc784cbba9c790c2cc083cf99d9a2a112a9c27 (diff) | |
download | Qt-b14338cce8cb13003a4943d134502e085f36ab08.zip Qt-b14338cce8cb13003a4943d134502e085f36ab08.tar.gz Qt-b14338cce8cb13003a4943d134502e085f36ab08.tar.bz2 |
Fix buglet in QGraphicsItem::stackBefore().
Reported by Alan. The stackBefore() implementation did not alter the
insertion order if the two items' current Z values were different. The
fix is to ensure it is updated, so that the stackBefore() operation
takes effect should the Z values become equal in the future. Example:
Current order: A-B-C-D
A->setZValue(1);
Current order: B-C-D-A (A moves to the end)
D->stackBefore(A);
Current order: B-C-D-A (unchanged, D is already before A)
A->setZValue(0);
Current order: D-A-B-C (now A moves back, and D moves in front)
Reviewed-by: Aaron Kennedy
Diffstat (limited to 'tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 4fae911..dabf64c 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -8569,24 +8569,24 @@ void tst_QGraphicsItem::stackBefore() QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child1 << child3 << child4 << child2)); // Move child2 before child1 - child2->stackBefore(child1); + child2->stackBefore(child1); // 2134 QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child1 << child3 << child4)); - child2->stackBefore(child2); + child2->stackBefore(child2); // 2134 QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child1 << child3 << child4)); - child1->setZValue(1); + child1->setZValue(1); // 2341 QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child3 << child4 << child1)); - child1->stackBefore(child2); // no effect + child1->stackBefore(child2); // 2341 QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child3 << child4 << child1)); - child1->setZValue(0); - QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child1 << child3 << child4)); - child4->stackBefore(child1); - QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child4 << child1 << child3)); - child4->setZValue(1); - QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child1 << child3 << child4)); - child3->stackBefore(child1); - QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child3 << child1 << child4)); - child4->setZValue(0); - QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child4 << child3 << child1)); + child1->setZValue(0); // 1234 + QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child1 << child2 << child3 << child4)); + child4->stackBefore(child1); // 4123 + QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child4 << child1 << child2 << child3)); + child4->setZValue(1); // 1234 (4123) + QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child1 << child2 << child3 << child4)); + child3->stackBefore(child1); // 3124 (4312) + QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child3 << child1 << child2 << child4)); + child4->setZValue(0); // 4312 + QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child4 << child3 << child1 << child2)); // Make them all toplevels child1->setParentItem(0); @@ -8608,24 +8608,24 @@ void tst_QGraphicsItem::stackBefore() QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child1 << child3 << child4 << child2)); // Move child2 before child1 - child2->stackBefore(child1); + child2->stackBefore(child1); // 2134 QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child1 << child3 << child4)); - child2->stackBefore(child2); + child2->stackBefore(child2); // 2134 QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child1 << child3 << child4)); - child1->setZValue(1); + child1->setZValue(1); // 2341 QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child3 << child4 << child1)); - child1->stackBefore(child2); // no effect + child1->stackBefore(child2); // 2341 QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child3 << child4 << child1)); - child1->setZValue(0); - QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child1 << child3 << child4)); - child4->stackBefore(child1); - QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child4 << child1 << child3)); - child4->setZValue(1); - QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child1 << child3 << child4)); - child3->stackBefore(child1); - QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child3 << child1 << child4)); - child4->setZValue(0); - QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child4 << child3 << child1)); + child1->setZValue(0); // 1234 + QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child1 << child2 << child3 << child4)); + child4->stackBefore(child1); // 4123 + QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child4 << child1 << child2 << child3)); + child4->setZValue(1); // 1234 (4123) + QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child1 << child2 << child3 << child4)); + child3->stackBefore(child1); // 3124 (4312) + QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child3 << child1 << child2 << child4)); + child4->setZValue(0); // 4312 + QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child4 << child3 << child1 << child2)); } void tst_QGraphicsItem::QTBUG_4233_updateCachedWithSceneRect() |