aboutsummaryrefslogtreecommitdiff
path: root/guilib
diff options
context:
space:
mode:
authorjmarshallnz <jmarshallnz@svn>2010-09-05 06:35:36 +0000
committerjmarshallnz <jmarshallnz@svn>2010-09-05 06:35:36 +0000
commit2305a1e7c44242f1b901a9517244c1b5b855c6ba (patch)
tree595f601a4a81d0f7735d0c80c9b74a5557b68c57 /guilib
parentac339c437ab15c1a38b3d08c3dd494e53a4ea41f (diff)
fixed: Ensure we don't divide by zero in the scrollbar positioning code.
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@33535 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'guilib')
-rw-r--r--guilib/GUIScrollBarControl.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/guilib/GUIScrollBarControl.cpp b/guilib/GUIScrollBarControl.cpp
index 42ddbaa014..a74dfc72fb 100644
--- a/guilib/GUIScrollBarControl.cpp
+++ b/guilib/GUIScrollBarControl.cpp
@@ -195,7 +195,7 @@ void CGUIScrollBar::UpdateBarSize()
if (m_orientation == VERTICAL)
{
// calculate the height to display the nib at
- float percent = (float)m_pageSize / m_numItems;
+ float percent = (m_numItems == 0) ? 0 : (float)m_pageSize / m_numItems;
float nibSize = GetHeight() * percent;
if (nibSize < m_guiNibFocus.GetTextureHeight() + 2 * MIN_NIB_SIZE) nibSize = m_guiNibFocus.GetTextureHeight() + 2 * MIN_NIB_SIZE;
if (nibSize > GetHeight()) nibSize = GetHeight();
@@ -220,7 +220,7 @@ void CGUIScrollBar::UpdateBarSize()
else
{
// calculate the height to display the nib at
- float percent = (float)m_pageSize / m_numItems;
+ float percent = (m_numItems == 0) ? 0 : (float)m_pageSize / m_numItems;
float nibSize = GetWidth() * percent + 0.5f;
if (nibSize < m_guiNibFocus.GetTextureWidth() + 2 * MIN_NIB_SIZE) nibSize = m_guiNibFocus.GetTextureWidth() + 2 * MIN_NIB_SIZE;
if (nibSize > GetWidth()) nibSize = GetWidth();
@@ -231,7 +231,7 @@ void CGUIScrollBar::UpdateBarSize()
m_guiNibFocus.SetWidth(nibSize);
// and the position
- percent = (float)m_offset / (m_numItems - m_pageSize);
+ percent = (m_numItems == m_pageSize) ? 0 : (float)m_offset / (m_numItems - m_pageSize);
float nibPos = (GetWidth() - nibSize) * percent;
if (nibPos < 0) nibPos = 0;
if (nibPos > GetWidth() - nibSize) nibPos = GetWidth() - nibSize;