[gimp] app: don't calculate balance when base == 1 in spiral, to avoid NaN



commit 8e946ca30723b2b328d1779b6d6563eeabeaf9c2
Author: Ell <ell_se yahoo com>
Date:   Sun Jul 30 07:23:08 2017 -0400

    app: don't calculate balance when base == 1 in spiral, to avoid NaN

 app/propgui/gimppropgui-spiral.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/app/propgui/gimppropgui-spiral.c b/app/propgui/gimppropgui-spiral.c
index 31ca87f..1e3eb9d 100644
--- a/app/propgui/gimppropgui-spiral.c
+++ b/app/propgui/gimppropgui-spiral.c
@@ -93,8 +93,11 @@ slider_line_callback (GObject                    *config,
         base = 1.0 / sliders[0].value;
         base = MIN (base, 1000000.0);
 
-        /* keep "balance" fixed when changing "base".  a bit ugly :P */
-        if (base == old_base)
+        /* keep "balance" fixed when changing "base", or when "base" is 1, in
+         * which case there's no inverse mapping for the slider value, and we
+         * can get NaN.
+         */
+        if (base == old_base && base > 1.0)
           {
             balance = -4.0 * log (sliders[1].value) / log (base) - 1.0;
             balance = CLAMP (balance, -1.0, 1.0);


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