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/graphicsitems/qdeclarativegridview.cpp | |
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/graphicsitems/qdeclarativegridview.cpp')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativegridview.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
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); |