[gimp/gimp-2-10] app: avoid applying buffer to drawable if application region is empty



commit 2e47f8277c09e87ae783cb1fc69068caebfd8ac7
Author: Ell <ell_se yahoo com>
Date:   Sat Sep 29 10:24:53 2018 -0400

    app: avoid applying buffer to drawable if application region is empty
    
    In gimp_drawable_real_{apply,replace}_buffer(), bail if the
    applcation region, after intersection with the drawable and mask
    extents, is empty.  This avoids trying to create a GeglBuffer with
    negative width/height.
    
    (cherry picked from commit ae3c006293deff496b813597ef2addc4cc56276f)

 app/core/gimpdrawable-combine.c | 56 +++++++++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 22 deletions(-)
---
diff --git a/app/core/gimpdrawable-combine.c b/app/core/gimpdrawable-combine.c
index cb904c41c5..9a4dccea1c 100644
--- a/app/core/gimpdrawable-combine.c
+++ b/app/core/gimpdrawable-combine.c
@@ -72,12 +72,15 @@ gimp_drawable_real_apply_buffer (GimpDrawable           *drawable,
   gimp_item_get_offset (item, &offset_x, &offset_y);
 
   /*  make sure the image application coordinates are within drawable bounds  */
-  gimp_rectangle_intersect (base_x, base_y,
-                            buffer_region->width, buffer_region->height,
-                            0, 0,
-                            gimp_item_get_width  (item),
-                            gimp_item_get_height (item),
-                            &x, &y, &width, &height);
+  if (! gimp_rectangle_intersect (base_x, base_y,
+                                  buffer_region->width, buffer_region->height,
+                                  0, 0,
+                                  gimp_item_get_width  (item),
+                                  gimp_item_get_height (item),
+                                  &x, &y, &width, &height))
+    {
+      return;
+    }
 
   if (mask)
     {
@@ -87,11 +90,14 @@ gimp_drawable_real_apply_buffer (GimpDrawable           *drawable,
        *  we need to add the layer offset to transform coords
        *  into the mask coordinate system
        */
-      gimp_rectangle_intersect (x, y, width, height,
-                                -offset_x, -offset_y,
-                                gimp_item_get_width  (mask_item),
-                                gimp_item_get_height (mask_item),
-                                &x, &y, &width, &height);
+      if (! gimp_rectangle_intersect (x, y, width, height,
+                                      -offset_x, -offset_y,
+                                      gimp_item_get_width  (mask_item),
+                                      gimp_item_get_height (mask_item),
+                                      &x, &y, &width, &height))
+        {
+          return;
+        }
     }
 
   if (push_undo)
@@ -197,12 +203,15 @@ gimp_drawable_real_replace_buffer (GimpDrawable        *drawable,
   gimp_item_get_offset (item, &offset_x, &offset_y);
 
   /*  make sure the image application coordinates are within drawable bounds  */
-  gimp_rectangle_intersect (dest_x, dest_y,
-                            buffer_rect.width, buffer_rect.height,
-                            0, 0,
-                            gimp_item_get_width  (item),
-                            gimp_item_get_height (item),
-                            &x, &y, &width, &height);
+  if (! gimp_rectangle_intersect (dest_x, dest_y,
+                                  buffer_rect.width, buffer_rect.height,
+                                  0, 0,
+                                  gimp_item_get_width  (item),
+                                  gimp_item_get_height (item),
+                                  &x, &y, &width, &height))
+    {
+      return;
+    }
 
   if (mask)
     {
@@ -212,11 +221,14 @@ gimp_drawable_real_replace_buffer (GimpDrawable        *drawable,
        *  we need to add the layer offset to transform coords
        *  into the mask coordinate system
        */
-      gimp_rectangle_intersect (x, y, width, height,
-                                -offset_x, -offset_y,
-                                gimp_item_get_width  (mask_item),
-                                gimp_item_get_height (mask_item),
-                                &x, &y, &width, &height);
+      if (! gimp_rectangle_intersect (x, y, width, height,
+                                      -offset_x, -offset_y,
+                                      gimp_item_get_width  (mask_item),
+                                      gimp_item_get_height (mask_item),
+                                      &x, &y, &width, &height))
+        {
+          return;
+        }
     }
 
   /*  adjust the original regions according to the application


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