[gimp/gimp-2-6] Bug 586008 - GIMP crashes when right-click canceling a drawing action initiated outside layer bounda



commit d617916a9325ef1ebc2863c5c507a4de22fa1a38
Author: Michael Natterer <mitch gimp org>
Date:   Tue Jun 16 22:09:48 2009 +0200

    Bug 586008 - GIMP crashes when right-click canceling a drawing action initiated outside layer boundaries
    
    (gimp_paint_core_cancel): don't pass out-of-drawable coordinates to
    gimp_paint_core_copy_valid_tiles().

 app/paint/gimppaintcore.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c
index baa1041..facf8f1 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -479,6 +479,9 @@ void
 gimp_paint_core_cancel (GimpPaintCore *core,
                         GimpDrawable  *drawable)
 {
+  gint x, y;
+  gint width, height;
+
   g_return_if_fail (GIMP_IS_PAINT_CORE (core));
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
@@ -489,11 +492,18 @@ gimp_paint_core_cancel (GimpPaintCore *core,
   if ((core->x2 == core->x1) || (core->y2 == core->y1))
     return;
 
-  gimp_paint_core_copy_valid_tiles (core->undo_tiles,
-                                    gimp_drawable_get_tiles (drawable),
-                                    core->x1, core->y1,
-                                    core->x2 - core->x1,
-                                    core->y2 - core->y1);
+  if (gimp_rectangle_intersect (core->x1, core->y1,
+                                core->x2 - core->x1,
+                                core->y2 - core->y1,
+                                0, 0,
+                                gimp_item_width  (GIMP_ITEM (drawable)),
+                                gimp_item_height (GIMP_ITEM (drawable)),
+                                &x, &y, &width, &height))
+    {
+      gimp_paint_core_copy_valid_tiles (core->undo_tiles,
+                                        gimp_drawable_get_tiles (drawable),
+                                        x, y, width, height);
+    }
 
   tile_manager_unref (core->undo_tiles);
   core->undo_tiles = NULL;
@@ -504,9 +514,7 @@ gimp_paint_core_cancel (GimpPaintCore *core,
       core->saved_proj_tiles = NULL;
     }
 
-  gimp_drawable_update (drawable,
-                        core->x1, core->y1,
-                        core->x2 - core->x1, core->y2 - core->y1);
+  gimp_drawable_update (drawable, x, y, width, height);
 
   gimp_viewable_preview_thaw (GIMP_VIEWABLE (drawable));
 }



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