diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-01-21 05:03:35 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2011-01-21 05:03:35 (GMT) |
commit | c3dd455b03a6c03011e2446f69fc262230e91639 (patch) | |
tree | 4400e080dc56d85012f063eea7178681eda505b4 /src/declarative | |
parent | 8c3086aa36b51a9731fce8eb8146b33ab8196aed (diff) | |
download | Qt-c3dd455b03a6c03011e2446f69fc262230e91639.zip Qt-c3dd455b03a6c03011e2446f69fc262230e91639.tar.gz Qt-c3dd455b03a6c03011e2446f69fc262230e91639.tar.bz2 |
positionViewAtIndex can fail when positioned near end of list.
We positioned the view beyond the bounds, which in some cases resulted
in only one item being created. Combined with a bug in the bounds
fixup very many items were created.
Task-number: QT-4441
Reviewed-by: Michael Brasser
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeflickable.cpp | 2 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativegridview.cpp | 4 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativelistview.cpp | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 4aaec38..dc7536e 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -299,7 +299,7 @@ void QDeclarativeFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal timeline.move(data.move, maxExtent - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4); timeline.move(data.move, maxExtent, QEasingCurve(QEasingCurve::OutExpo), 3*fixupDuration/4); } else { - timeline.set(data.move, minExtent); + timeline.set(data.move, maxExtent); } } vTime = timeline.time(); diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 89d7493..4c04a6b 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -2165,6 +2165,7 @@ void QDeclarativeGridView::positionViewAtIndex(int index, int mode) if (d->layoutScheduled) d->layout(); qreal pos = d->position(); + qreal maxExtent = d->flow == QDeclarativeGridView::LeftToRight ? -maxYExtent() : -maxXExtent(); FxGridItem *item = d->visibleItem(index); if (!item) { int itemPos = d->rowPosAt(index); @@ -2172,7 +2173,7 @@ void QDeclarativeGridView::positionViewAtIndex(int index, int mode) QList<FxGridItem*> oldVisible = d->visibleItems; d->visibleItems.clear(); d->visibleIndex = index - index % d->columns; - d->setPosition(itemPos); + d->setPosition(qMin(qreal(itemPos), maxExtent)); // now release the reference to all the old visible items. for (int i = 0; i < oldVisible.count(); ++i) d->releaseItem(oldVisible.at(i)); @@ -2202,7 +2203,6 @@ void QDeclarativeGridView::positionViewAtIndex(int index, int mode) if (itemPos < pos) pos = itemPos; } - qreal maxExtent = d->flow == QDeclarativeGridView::LeftToRight ? -maxYExtent() : -maxXExtent(); pos = qMin(pos, maxExtent); qreal minExtent = d->flow == QDeclarativeGridView::LeftToRight ? -minYExtent() : -minXExtent(); pos = qMax(pos, minExtent); diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index b4fd571..b4b3fa7 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -2603,6 +2603,7 @@ void QDeclarativeListView::positionViewAtIndex(int index, int mode) d->layout(); qreal pos = d->position(); FxListItem *item = d->visibleItem(index); + qreal maxExtent = d->orient == QDeclarativeListView::Vertical ? -maxYExtent() : -maxXExtent(); if (!item) { int itemPos = d->positionAt(index); // save the currently visible items in case any of them end up visible again @@ -2610,7 +2611,7 @@ void QDeclarativeListView::positionViewAtIndex(int index, int mode) d->visibleItems.clear(); d->visiblePos = itemPos; d->visibleIndex = index; - d->setPosition(itemPos); + d->setPosition(qMin(qreal(itemPos), maxExtent)); // now release the reference to all the old visible items. for (int i = 0; i < oldVisible.count(); ++i) d->releaseItem(oldVisible.at(i)); @@ -2640,7 +2641,6 @@ void QDeclarativeListView::positionViewAtIndex(int index, int mode) if (itemPos < pos) pos = itemPos; } - qreal maxExtent = d->orient == QDeclarativeListView::Vertical ? -maxYExtent() : -maxXExtent(); pos = qMin(pos, maxExtent); qreal minExtent = d->orient == QDeclarativeListView::Vertical ? -minYExtent() : -minXExtent(); pos = qMax(pos, minExtent); |