[gimp] app: fix propgui random seed generation



commit 07c81abf018d68c50e4861b567328b79df1f0c9f
Author: Ell <ell_se yahoo com>
Date:   Fri May 4 13:34:21 2018 -0400

    app: fix propgui random seed generation
    
    After the switch of random-seed properties from INT to UINT, their
    upper bound results in a negative value when converted to a
    gint32, causing a CRITICAL in the call to g_random_int_range().
    Use g_random_double_range() instead, which has enough precision to
    accurately represent all values in the range, and round the result.

 app/propgui/gimppropgui-utils.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/app/propgui/gimppropgui-utils.c b/app/propgui/gimppropgui-utils.c
index 8c77aca..a601e39 100644
--- a/app/propgui/gimppropgui-utils.c
+++ b/app/propgui/gimppropgui-utils.c
@@ -23,6 +23,7 @@
 #include <gegl.h>
 #include <gtk/gtk.h>
 
+#include "libgimpmath/gimpmath.h"
 #include "libgimpwidgets/gimpwidgets.h"
 
 #include "propgui-types.h"
@@ -211,8 +212,10 @@ static void
 gimp_prop_random_seed_new_clicked (GtkButton     *button,
                                    GtkAdjustment *adj)
 {
-  guint32 value = g_random_int_range (gtk_adjustment_get_lower (adj),
-                                      gtk_adjustment_get_upper (adj));
+  guint32 value;
+
+  value = floor (g_random_double_range (gtk_adjustment_get_lower (adj),
+                                        gtk_adjustment_get_upper (adj) + 1.0));
 
   gtk_adjustment_set_value (adj, value);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]