summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-10-15 11:46:17 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-10-16 13:53:03 +0200
commite2b3d42f946a7702a92412f8c603f13ad53a4566 (patch)
tree1a2f5387f6f0f371449e4cb15dbe1950d623e1bd /src/widgets/itemviews
parent0f1008a5936c903ca9448193df7df6117e2c617b (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 Pick-to: 5.15 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>
Diffstat (limited to 'src/widgets/itemviews')
-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 f3e0e06a56..502d64eaf6 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -3347,7 +3347,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)) {