aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickrepeater.cpp
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@viroteck.net>2014-11-04 18:23:45 -0800
committerRobin Burchell <robin.burchell@viroteck.net>2014-11-07 18:39:15 +0100
commit9d1cd3098a066c7b6689d4776bfd3a25621a26fc (patch)
tree382ee7f41a48d8d2feca29892a4bda3c603e477a /src/quick/items/qquickrepeater.cpp
parentb340caa0d3ebf7f76c0445b2cdd4032d8e3bf8d5 (diff)
QQuickRepeater::clear: Remove items from the end backwards.
This way, the indices for itemRemoved will make sense consistently. This was broken with 5f5aba5b6e690ca54e66f41b93474f7e67e83c8b, dated November 2011. Task-number: QTBUG-42243 Change-Id: I5fecfd4174049f51e0cec90e40e6332de5d5bf01 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/quick/items/qquickrepeater.cpp')
-rw-r--r--src/quick/items/qquickrepeater.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/quick/items/qquickrepeater.cpp b/src/quick/items/qquickrepeater.cpp
index e2a3043857..975682192e 100644
--- a/src/quick/items/qquickrepeater.cpp
+++ b/src/quick/items/qquickrepeater.cpp
@@ -350,7 +350,9 @@ void QQuickRepeater::clear()
bool complete = isComponentComplete();
if (d->model) {
- for (int i = 0; i < d->deletables.count(); ++i) {
+ // We remove in reverse order deliberately; so that signals are emitted
+ // with sensible indices.
+ for (int i = d->deletables.count() - 1; i >= 0; --i) {
if (QQuickItem *item = d->deletables.at(i)) {
if (complete)
emit itemRemoved(i, item);