diff options
author | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2010-07-26 18:51:32 (GMT) |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2010-07-27 07:39:41 (GMT) |
commit | 3c7e7992461b1fef37ada68244f1b5b891015bda (patch) | |
tree | 8e6ecd155eee728f1239f61168a884a48eea2355 /src/gui/itemviews | |
parent | db501e24d460231590c7e30cb8704c132efc3e8e (diff) | |
download | Qt-3c7e7992461b1fef37ada68244f1b5b891015bda.zip Qt-3c7e7992461b1fef37ada68244f1b5b891015bda.tar.gz Qt-3c7e7992461b1fef37ada68244f1b5b891015bda.tar.bz2 |
Fix crash when all the items in a QListView are hidden
Calling QIconModeViewBase::initDynamicLayout() on the second and
successive segments would return QPoint(-1,-1), resulting in a
totally empty area rectangle for all the items while in
QIconModeViewBase::doDynamicLayout(). This rectangle is used to
initialize the BSP tree, and produces an arithmetic exception when
empty.
Furthermore, a rendering bug was also apparent when displaying the
first item of a segment while the last item of the previous segment
was hidden.
Auto-tests included.
Reviewed-by: Olivier
Task-number: QTBUG-12308
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r-- | src/gui/itemviews/qlistview.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index b2def39..64ae0db 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -2773,7 +2773,10 @@ QPoint QIconModeViewBase::initDynamicLayout(const QListViewLayoutInfo &info) y = info.bounds.y() + info.spacing; items.reserve(rowCount() - hiddenCount()); } else { - const QListViewItem item = items.at(info.first - 1); + int idx = info.first - 1; + while (idx > 0 && !items.at(idx).isValid()) + --idx; + const QListViewItem &item = items.at(idx); x = item.x; y = item.y; if (info.flow == QListView::LeftToRight) @@ -2899,6 +2902,8 @@ void QIconModeViewBase::doDynamicLayout(const QListViewLayoutInfo &info) // resize the content area if (done || !info.bounds.contains(item->rect())) contentsSize = QSize(rect.width(), rect.height()); + if (rect.size().isEmpty()) + return; // resize tree int insertFrom = info.first; if (done || info.first == 0) { |