[gimp] pdb: never pass bogus supersample values to gimp_drawable_gradient()



commit 410e55c40c09f5623d80dbbf91e185dfefb22c67
Author: Michael Natterer <mitch gimp org>
Date:   Mon Apr 16 01:18:05 2018 +0200

    pdb: never pass bogus supersample values to gimp_drawable_gradient()
    
    even when supersampling is not enabled, or we will get warnings about
    out-of-range property values.

 app/pdb/drawable-edit-cmds.c |   20 ++++++++++++++------
 app/pdb/edit-cmds.c          |   18 +++++++++++++-----
 pdb/groups/drawable_edit.pdb |   20 ++++++++++++++------
 pdb/groups/edit.pdb          |   18 +++++++++++++-----
 4 files changed, 54 insertions(+), 22 deletions(-)
---
diff --git a/app/pdb/drawable-edit-cmds.c b/app/pdb/drawable-edit-cmds.c
index 7dcb2d5..387afd6 100644
--- a/app/pdb/drawable-edit-cmds.c
+++ b/app/pdb/drawable-edit-cmds.c
@@ -228,14 +228,22 @@ drawable_edit_gradient_fill_invoker (GimpProcedure         *procedure,
                                             GIMP_PDB_ITEM_CONTENT, error) &&
                  gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error));
 
-      if (success && supersample)
+      if (success)
         {
-          if (supersample_max_depth < 1 || supersample_max_depth > 9)
-            success = FALSE;
+          if (supersample)
+            {
+              if (supersample_max_depth < 1 || supersample_max_depth > 9)
+                success = FALSE;
 
-          if (supersample_threshold < 0.0 || supersample_threshold > 4.0)
-            success = FALSE;
-        }
+              if (supersample_threshold < 0.0 || supersample_threshold > 4.0)
+                success = FALSE;
+            }
+          else
+            {
+              supersample_max_depth = CLAMP (supersample_max_depth, 1, 9);
+              supersample_threshold = CLAMP (supersample_threshold, 0.0, 4.0);
+            }
+       }
 
       if (success)
         {
diff --git a/app/pdb/edit-cmds.c b/app/pdb/edit-cmds.c
index d04d0cc..ddf8894 100644
--- a/app/pdb/edit-cmds.c
+++ b/app/pdb/edit-cmds.c
@@ -777,13 +777,21 @@ edit_blend_invoker (GimpProcedure         *procedure,
                                             GIMP_PDB_ITEM_CONTENT, error) &&
                  gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error));
 
-      if (success && supersample)
+      if (success)
         {
-          if (max_depth < 1 || max_depth > 9)
-            success = FALSE;
+          if (supersample)
+            {
+              if (max_depth < 1 || max_depth > 9)
+                success = FALSE;
 
-          if (threshold < 0.0 || threshold > 4.0)
-            success = FALSE;
+              if (threshold < 0.0 || threshold > 4.0)
+                success = FALSE;
+            }
+          else
+            {
+              max_depth = CLAMP (max_depth, 1, 9);
+              threshold = CLAMP (threshold, 0.0, 4.0);
+            }
         }
 
       if (success)
diff --git a/pdb/groups/drawable_edit.pdb b/pdb/groups/drawable_edit.pdb
index a863526..c0dfb4c 100644
--- a/pdb/groups/drawable_edit.pdb
+++ b/pdb/groups/drawable_edit.pdb
@@ -247,14 +247,22 @@ HELP
                                         GIMP_PDB_ITEM_CONTENT, error) &&
              gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error));
 
-  if (success && supersample)
+  if (success)
     {
-      if (supersample_max_depth < 1 || supersample_max_depth > 9)
-        success = FALSE;
+      if (supersample)
+        {
+          if (supersample_max_depth < 1 || supersample_max_depth > 9)
+            success = FALSE;
 
-      if (supersample_threshold < 0.0 || supersample_threshold > 4.0)
-        success = FALSE;
-    }
+          if (supersample_threshold < 0.0 || supersample_threshold > 4.0)
+            success = FALSE;
+       }
+      else
+        {
+         supersample_max_depth = CLAMP (supersample_max_depth, 1, 9);
+         supersample_threshold = CLAMP (supersample_threshold, 0.0, 4.0);
+       }
+   }
 
   if (success)
     {
diff --git a/pdb/groups/edit.pdb b/pdb/groups/edit.pdb
index 75c7ade..3b04b04 100644
--- a/pdb/groups/edit.pdb
+++ b/pdb/groups/edit.pdb
@@ -869,13 +869,21 @@ HELP
                                         GIMP_PDB_ITEM_CONTENT, error) &&
              gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error));
 
-  if (success && supersample)
+  if (success)
     {
-      if (max_depth < 1 || max_depth > 9)
-        success = FALSE;
+      if (supersample)
+        {
+          if (max_depth < 1 || max_depth > 9)
+            success = FALSE;
 
-      if (threshold < 0.0 || threshold > 4.0)
-        success = FALSE;
+          if (threshold < 0.0 || threshold > 4.0)
+            success = FALSE;
+       }
+      else
+        {
+         max_depth = CLAMP (max_depth, 1, 9);
+         threshold = CLAMP (threshold, 0.0, 4.0);
+       }
     }
 
   if (success)


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