[gtk+/wip/baedert/drawing: 308/359] range: Avoid division by zero
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baedert/drawing: 308/359] range: Avoid division by zero
- Date: Thu, 13 Jul 2017 14:53:40 +0000 (UTC)
commit 5f4c49107114921b4f6bcb203c19cc5d87a42a10
Author: Timm Bäder <mail baedert org>
Date: Thu Jun 29 15:28:24 2017 +0200
range: Avoid division by zero
gtk/gtkrange.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index f74f1b2..2c4d208 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -1425,8 +1425,11 @@ gtk_range_allocate_trough (GtkGizmo *gizmo,
gtk_widget_size_allocate (priv->slider_widget, &slider_alloc);
gtk_widget_get_clip (priv->slider_widget, out_clip);
- value = (gtk_adjustment_get_value (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment)) /
- (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment));
+ if (gtk_adjustment_get_lower (priv->adjustment) == gtk_adjustment_get_upper (priv->adjustment))
+ value = 0;
+ else
+ value = (gtk_adjustment_get_value (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment)) /
+ (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment));
if (priv->show_fill_level &&
gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment) -
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]