summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-10-21 15:31:18 (GMT)
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-10-21 15:54:48 (GMT)
commit9c136d34c1d15d077ab5103a84dfb2449b796d1f (patch)
tree942968483034890c17a1ad7eef4a7d2e8c5d1ba3
parent27abb4acf6fec8d9c2f18242ce539ebbc905eefc (diff)
downloadQt-9c136d34c1d15d077ab5103a84dfb2449b796d1f.zip
Qt-9c136d34c1d15d077ab5103a84dfb2449b796d1f.tar.gz
Qt-9c136d34c1d15d077ab5103a84dfb2449b796d1f.tar.bz2
Fixed crash in tst_qabstractitemview.
Reviewed-by: trust-me
-rw-r--r--src/gui/itemviews/qlistview.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
index b6e0ab7..f58f458 100644
--- a/src/gui/itemviews/qlistview.cpp
+++ b/src/gui/itemviews/qlistview.cpp
@@ -1939,7 +1939,11 @@ int QListModeViewBase::verticalScrollToValue(int index, QListView::ScrollHint hi
bool above, bool below, const QRect &area, const QRect &rect) const
{
if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) {
- int value = qBound(0, scrollValueMap.at(verticalScrollBar()->value()), flowPositions.count() - 1);
+ int value;
+ if (scrollValueMap.isEmpty())
+ value = 0;
+ else
+ value = qBound(0, scrollValueMap.at(verticalScrollBar()->value()), flowPositions.count() - 1);
if (above)
hint = QListView::PositionAtTop;
else if (below)
@@ -2000,7 +2004,11 @@ int QListModeViewBase::horizontalScrollToValue(int index, QListView::ScrollHint
if (horizontalScrollMode() != QAbstractItemView::ScrollPerItem)
return QCommonListViewBase::horizontalScrollToValue(index, hint, leftOf, rightOf, area, rect);
- int value = qBound(0, scrollValueMap.at(horizontalScrollBar()->value()), flowPositions.count() - 1);
+ int value;
+ if (scrollValueMap.isEmpty())
+ value = 0;
+ else
+ value = qBound(0, scrollValueMap.at(horizontalScrollBar()->value()), flowPositions.count() - 1);
if (leftOf)
hint = QListView::PositionAtTop;
else if (rightOf)
@@ -2312,7 +2320,7 @@ int QListModeViewBase::perItemScrollingPageSteps(int length, int bounds, bool wr
QVector<int> positions;
if (wrap)
positions = segmentPositions;
- else {
+ else if (!flowPositions.isEmpty()) {
positions.reserve(scrollValueMap.size());
foreach (int itemShown, scrollValueMap)
positions.append(flowPositions.at(itemShown));