[gtk+/wip/baedert/drawing: 2/3] range: Avoid division by zero



commit c5c7d07614d25cc74b7fb1305e8978cf1b96860d
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]