From c2f9d8a99db280941237b7ed35052547d55bd014 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 25 Sep 2017 15:22:28 +0200 Subject: ObjectModel: provide unique move IDs QQuickItemViewPrivate::removeItem() uses a QHash to store items that were removed due to a move. If the move IDs are not unique, multiple buffered moves end up overriding each other. This results to leaked items that are never released. Task-number: QTBUG-62607 Change-Id: I7e7e7fcd6b1b0aa50ed55643ba5674e98536f89f Reviewed-by: Mitch Curtis Reviewed-by: Michael Brasser --- tests/auto/qml/qqmlobjectmodel/tst_qqmlobjectmodel.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmlobjectmodel/tst_qqmlobjectmodel.cpp b/tests/auto/qml/qqmlobjectmodel/tst_qqmlobjectmodel.cpp index 6ac0412ae5..fb63d811a8 100644 --- a/tests/auto/qml/qqmlobjectmodel/tst_qqmlobjectmodel.cpp +++ b/tests/auto/qml/qqmlobjectmodel/tst_qqmlobjectmodel.cpp @@ -47,18 +47,18 @@ static bool compareItems(QQmlObjectModel *model, const QObjectList &items) return true; } -static bool verifyChangeSet(const QQmlChangeSet &changeSet, int expectedInserts, int expectedRemoves, bool isMove) +static bool verifyChangeSet(const QQmlChangeSet &changeSet, int expectedInserts, int expectedRemoves, bool isMove, int moveId = -1) { int actualRemoves = 0; for (const QQmlChangeSet::Change &r : changeSet.removes()) { - if (r.isMove() != isMove) + if (r.isMove() != isMove && (!isMove || moveId == r.moveId)) return false; actualRemoves += r.count; } int actualInserts = 0; for (const QQmlChangeSet::Change &i : changeSet.inserts()) { - if (i.isMove() != isMove) + if (i.isMove() != isMove && (!isMove || moveId == i.moveId)) return false; actualInserts += i.count; } @@ -129,7 +129,7 @@ void tst_QQmlObjectModel::changes() QCOMPARE(countSpy.count(), countSignals); QCOMPARE(childrenSpy.count(), ++childrenSignals); QCOMPARE(modelUpdateSpy.count(), ++modelUpdateSignals); - QVERIFY(verifyChangeSet(modelUpdateSpy.last().first().value(), 1, 1, true)); + QVERIFY(verifyChangeSet(modelUpdateSpy.last().first().value(), 1, 1, true, 1)); // move(3, 2) -> [item0, item1, item2, item3] model.move(3, 2); items.move(3, 2); @@ -138,7 +138,7 @@ void tst_QQmlObjectModel::changes() QCOMPARE(countSpy.count(), countSignals); QCOMPARE(childrenSpy.count(), ++childrenSignals); QCOMPARE(modelUpdateSpy.count(), ++modelUpdateSignals); - QVERIFY(verifyChangeSet(modelUpdateSpy.last().first().value(), 1, 1, true)); + QVERIFY(verifyChangeSet(modelUpdateSpy.last().first().value(), 1, 1, true, 2)); // remove(0) -> [item1, item2, item3] model.remove(0); items.removeAt(0); -- cgit v1.2.3