[gimp/blend-tool-fun: 117/163] plug-ins: fix 2 bugs in fractal-trace



commit 01199f6f62918cccd2e22bffe5758ad14123c6d3
Author: Andrew Worsley <amworsley gmail com>
Date:   Fri Oct 2 20:45:21 2015 +1000

    plug-ins: fix 2 bugs in fractal-trace
    
    - crashes when computing % 0 when selection height < 100
    - used y2 instead of x2 when computing width
    - crash when selection in lower left corner

 plug-ins/common/fractal-trace.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/plug-ins/common/fractal-trace.c b/plug-ins/common/fractal-trace.c
index 47331e3..a0d20f1 100644
--- a/plug-ins/common/fractal-trace.c
+++ b/plug-ins/common/fractal-trace.c
@@ -179,7 +179,7 @@ run (const gchar      *name,
   gimp_drawable_mask_bounds (drawable->drawable_id,
                              &selection.x1, &selection.y1,
                              &selection.x2, &selection.y2);
-  selection.width    = selection.x2 - selection.y1;
+  selection.width    = selection.x2 - selection.x1;
   selection.height   = selection.y2 - selection.y1;
   selection.center_x = selection.x1 + (gdouble) selection.width / 2.0;
   selection.center_y = selection.y1 + (gdouble) selection.height / 2.0;
@@ -456,9 +456,15 @@ filter (GimpDrawable *drawable)
   gdouble scale_x, scale_y;
   gdouble cx, cy;
   gdouble px, py;
+  gint h_percent;
 
   gimp_progress_init (_("Fractal Trace"));
 
+  if (selection.width == 0 || selection.height == 0)
+    return;
+
+  h_percent = selection.height / 100;
+
   scale_x = (parameters.x2 - parameters.x1) / selection.width;
   scale_y = (parameters.y2 - parameters.y1) / selection.height;
 
@@ -503,7 +509,7 @@ filter (GimpDrawable *drawable)
           pixels_set (x, y, &pixel);
         }
 
-      if (((y - selection.y1) % (selection.height / 100)) == 0)
+      if (h_percent == 0 || ((y - selection.y1) % h_percent) == 0)
         gimp_progress_update ((gdouble) (y-selection.y1) / selection.height);
     }
 


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