aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativelistview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativelistview.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 8d2fd93e2b..225b031530 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.
@@ -940,7 +943,9 @@ void QDeclarativeListViewPrivate::createHighlight()
if (highlight) {
if (trackedItem == highlight)
trackedItem = 0;
- delete highlight->item;
+ if (highlight->item->scene())
+ highlight->item->scene()->removeItem(highlight->item);
+ highlight->item->deleteLater();
delete highlight;
highlight = 0;
delete highlightPosAnimator;
@@ -3406,9 +3411,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);