[gimp] app: Handle zero radius in gimp_channel_border()



commit 8b11a505d95f53aa16045d8f7e42cdf9b5faca4c
Author: Ell <ell_se yahoo com>
Date:   Mon Apr 4 17:25:45 2016 +0000

    app: Handle zero radius in gimp_channel_border()
    
    Can only be triggered through PDB.  Currently assigns illegal values
    to the GEGL ops' properties.

 app/core/gimpchannel.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index 9a3463e..11bdd1c 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -1415,8 +1415,24 @@ gimp_channel_real_border (GimpChannel            *channel,
 {
   gint x1, y1, x2, y2;
 
-  if (radius_x < 0 || radius_y < 0)
-    return;
+  if (radius_x == 0 && radius_y == 0)
+    {
+      /* The relevant GEGL operations require radius_x and radius_y to be > 0.
+       * When both are 0 (currently can only be achieved by the user through
+       * PDB), the effect should be to clear the channel.
+       */
+      gimp_channel_clear (channel,
+                          GIMP_CHANNEL_GET_CLASS (channel)->border_desc,
+                          push_undo);
+      return;
+    }
+  else if (radius_x <= 0 || radius_y <= 0)
+    {
+      /* FIXME: Implement the case where only one of radius_x and radius_y is 0.
+       * Currently, should never happen.
+       */
+      g_return_if_reached();
+    }
 
   if (! gimp_item_bounds (GIMP_ITEM (channel), &x1, &y1, &x2, &y2))
     return;


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