summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-10-15 11:46:17 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-10-16 15:48:27 +0000
commit19a41e6aa5cba5f664d8ea52337d71e6d3ba2b45 (patch)
tree700994e1ee279b8ad305bb1a92733390d6d63dd9 /src
parente356239397def8540ca2ec82274830a6c980a1a7 (diff)
Don't divide by zero when calculating number of items
Amends e74af68654c0eb127277c73e20bda409b83d157b. If the model has children, then row 0 should have a non-zero size, but it's not unthinkable that a delegate returns zero for size hint, so protect against that case. Task-number: QTBUG-87588 Change-Id: Ia396f532d42ce5fad8757d629816c3cdc31d84ed Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Florian Bruhin <qt-project.org@the-compiler.org> (cherry picked from commit e2b3d42f946a7702a92412f8c603f13ad53a4566) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/itemviews/qtreeview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 37889fd66b..b778ef9a47 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -3322,7 +3322,7 @@ void QTreeViewPrivate::layout(int i, bool recursiveExpanding, bool afterIsUninit
model->fetchMore(parent);
// guestimate the number of items in the viewport, and fetch as many as might fit
const int itemHeight = defaultItemHeight <= 0 ? q->sizeHintForRow(0) : defaultItemHeight;
- const int viewCount = viewport->height() / itemHeight;
+ const int viewCount = itemHeight ? viewport->height() / itemHeight : 0;
int lastCount = -1;
while ((count = model->rowCount(parent)) < viewCount &&
count != lastCount && model->canFetchMore(parent)) {