diff options
author | Bea Lam <bea.lam@nokia.com> | 2011-11-10 14:30:08 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-16 04:39:26 +0100 |
commit | 80615c3036e689061588a144339125b7fb8e66e5 (patch) | |
tree | 195ce893dd0a15d486550b2a8a08b285b9ec3102 /src | |
parent | eef97750eb1c5b33ed8e0e8c0d1bbf6385239701 (diff) |
Fix refill where zero-size items are involved
881091b5c0f1d2ead2b70e54f7ac2e4c17680b4e was incorrect since it meant
that any items following zero-sized delegates would not be deleted as
they scrolled up past the top of the view.
refill() should be deleting these items as well as any zero-sized items
before them.
Task-number: QTBUG-22014
Change-Id: I10cd30bb85a8ec1ddaa2a1cbaa924192536ef6fc
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/items/qquicklistview.cpp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/declarative/items/qquicklistview.cpp b/src/declarative/items/qquicklistview.cpp index 9dc91309f1..4fd4e97da5 100644 --- a/src/declarative/items/qquicklistview.cpp +++ b/src/declarative/items/qquicklistview.cpp @@ -634,18 +634,34 @@ bool QQuickListViewPrivate::removeNonVisibleItems(qreal bufferFrom, qreal buffer FxViewItem *item = 0; bool changed = false; - while (visibleItems.count() > 1 && (item = visibleItems.first()) && item->endPosition() <= bufferFrom) { + // Remove items from the start of the view. + // Zero-sized items shouldn't be removed unless a non-zero-sized item is also being + // removed, otherwise a zero-sized item is infinitely added and removed over and + // over by refill(). + int index = 0; + while (visibleItems.count() > 1 && index < visibleItems.count() + && (item = visibleItems.at(index)) && item->endPosition() <= bufferFrom) { if (item->attached->delayRemove()) break; - if (item->size() == 0) - break; + if (item->size() > 0) { // qDebug() << "refill: remove first" << visibleIndex << "top end pos" << item->endPosition(); - if (item->index != -1) - visibleIndex++; - visibleItems.removeFirst(); - releaseItem(item); - changed = true; + + // remove this item and all zero-sized items before it + while (item) { + if (item->index != -1) + visibleIndex++; + visibleItems.removeAt(index); + releaseItem(item); + if (index == 0) + break; + item = visibleItems.at(--index); + } + changed = true; + } else { + index++; + } } + while (visibleItems.count() > 1 && (item = visibleItems.last()) && item->position() > bufferTo) { if (item->attached->delayRemove()) break; |