From 162b52e7e95e3fcd747fb4b1867bcc54e603c266 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Mon, 26 Sep 2011 16:42:17 +1000 Subject: [PATCH] Don't give move ids to moved inserts. Move ids identify a paired remove and insert, an insert that has a move id but no corresponding remove breaks anything relying on that identity. Change-Id: I9512e298bc518c5abf5bca7523a375baf8a39407 Reviewed-on: http://codereview.qt-project.org/5512 Reviewed-by: Qt Sanity Bot Reviewed-by: Andrew den Exter --- src/declarative/util/qdeclarativechangeset.cpp | 3 ++- .../qdeclarativechangeset/tst_qdeclarativechangeset.cpp | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/declarative/util/qdeclarativechangeset.cpp b/src/declarative/util/qdeclarativechangeset.cpp index d941d5e..9e87593 100644 --- a/src/declarative/util/qdeclarativechangeset.cpp +++ b/src/declarative/util/qdeclarativechangeset.cpp @@ -219,7 +219,8 @@ void QDeclarativeChangeSet::applyRemovals(QVector &removals, QVectormoveId != -1 && difference > 0) { - iit = insertions.insert(iit, Insert(iit->index, difference, moveId)); + iit = insertions.insert(iit, Insert( + iit->index, difference, insert->moveId != -1 ? moveId : -1)); ++iit; iit->index += difference; iit->count -= difference; diff --git a/tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp b/tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp index 4aaefba..6b3fcf9 100644 --- a/tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp +++ b/tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp @@ -132,8 +132,13 @@ private slots: void sequence(); }; -bool operator ==(const tst_qdeclarativemodelchange::Signal &left, const tst_qdeclarativemodelchange::Signal &right) { - return left.index == right.index && left.count == right.count && left.to == right.to; } +bool operator ==(const tst_qdeclarativemodelchange::Signal &left, const tst_qdeclarativemodelchange::Signal &right) +{ + return left.index == right.index + && left.count == right.count + && left.to == right.to + && ((left.moveId == -1 && right.moveId == -1) || left.moveId != -1 && right.moveId != -1); +} QDebug operator <<(QDebug debug, const tst_qdeclarativemodelchange::Signal &signal) -- 2.7.4