summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-02-09 21:04:00 +0100
committerPetr Mrázek <peterix@gmail.com>2014-02-09 21:04:00 +0100
commitba401922e1577d629e8b01bffa73f5e721b17b59 (patch)
tree05c961a540460d780a0ecc98f0c94bc237c32310 /gui
parent1f6a484cb2368a5704cdb4820ac06194ea6d7e1a (diff)
downloadMultiMC-ba401922e1577d629e8b01bffa73f5e721b17b59.tar
MultiMC-ba401922e1577d629e8b01bffa73f5e721b17b59.tar.gz
MultiMC-ba401922e1577d629e8b01bffa73f5e721b17b59.tar.lz
MultiMC-ba401922e1577d629e8b01bffa73f5e721b17b59.tar.xz
MultiMC-ba401922e1577d629e8b01bffa73f5e721b17b59.zip
Do not divide by zero when the last group is collapsed.
Diffstat (limited to 'gui')
-rw-r--r--gui/groupview/GroupView.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/gui/groupview/GroupView.cpp b/gui/groupview/GroupView.cpp
index 5ee44cbb..3f7dd6e0 100644
--- a/gui/groupview/GroupView.cpp
+++ b/gui/groupview/GroupView.cpp
@@ -116,19 +116,20 @@ void GroupView::updateGeometries()
int totalHeight = 0;
// top margin
totalHeight += m_categoryMargin;
+ int itemScroll = 0;
for (auto category : m_groups)
{
category->m_verticalPosition = totalHeight;
totalHeight += category->totalHeight() + m_categoryMargin;
+ if(!itemScroll && category->totalHeight() != 0)
+ {
+ itemScroll = category->contentHeight() / category->numRows();
+ }
}
- auto category = m_groups.last();
- int itemScroll = category->contentHeight() / category->numRows();
- /*
- // remove the last margin (we don't want it)
- totalHeight -= m_categoryMargin;
- // add a margin on top...
- totalHeight += m_categoryMargin;
- */
+ // do not divide by zero
+ if(itemScroll == 0)
+ itemScroll = 64;
+
totalHeight += m_bottomMargin;
verticalScrollBar()->setSingleStep ( itemScroll );
const int rowsPerPage = qMax ( viewport()->height() / itemScroll, 1 );