summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-05-13 05:28:30 (GMT)
committerMartin Jones <martin.jones@nokia.com>2011-05-13 05:28:30 (GMT)
commit576d577438f1193bbc934e904b809d5b23b8d54e (patch)
tree900f0de9c10ed59b48f1eab73de1447615d49630 /src
parentf69e465e15930ef02dceba7175eed6f3f1df070e (diff)
downloadQt-576d577438f1193bbc934e904b809d5b23b8d54e.zip
Qt-576d577438f1193bbc934e904b809d5b23b8d54e.tar.gz
Qt-576d577438f1193bbc934e904b809d5b23b8d54e.tar.bz2
ListViews loses items if all visible items are removed.
Occurs when at end of list and all visible items are removed in multiple steps, without entering the event loop. We were not updating visibleIndex if there were no visible items when handling itemsRemoved(). Also avoid skipping items in refill if there are no valid visible items for reference. Change-Id: I2ff58fb191f6b053f33d5446220d597eb15b66d4 Task-number: QTBUG-19198 Reviewed-by: Bea Lam
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index cb40384..79d67e7 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -733,6 +733,7 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer)
if (doBuffer && (bufferMode & BufferBefore))
fillFrom = bufferFrom;
+ bool haveValidItems = false;
int modelIndex = visibleIndex;
qreal itemEnd = visiblePos-1;
if (!visibleItems.isEmpty()) {
@@ -741,11 +742,13 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer)
int i = visibleItems.count() - 1;
while (i > 0 && visibleItems.at(i)->index == -1)
--i;
- if (visibleItems.at(i)->index != -1)
+ if (visibleItems.at(i)->index != -1) {
+ haveValidItems = true;
modelIndex = visibleItems.at(i)->index + 1;
+ }
}
- if (visibleItems.count() && (fillFrom > itemEnd+averageSize+spacing
+ if (haveValidItems && (fillFrom > itemEnd+averageSize+spacing
|| fillTo < visiblePos - averageSize - spacing)) {
// We've jumped more than a page. Estimate which items are now
// visible and fill from there.
@@ -3406,9 +3409,9 @@ void QDeclarativeListView::itemsRemoved(int modelIndex, int count)
}
}
- if (removedVisible && !haveVisibleIndex) {
+ if (!haveVisibleIndex) {
d->timeline.clear();
- if (d->itemCount == 0) {
+ if (removedVisible && d->itemCount == 0) {
d->visibleIndex = 0;
d->visiblePos = d->header ? d->header->size() : 0;
d->setPosition(0);