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



commit 06a3b3a85a01403db4262e80e9cf63005be40dbd
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 8af5647..32de5a2 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -490,6 +490,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)));
@@ -500,11 +503,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_get_width  (GIMP_ITEM (drawable)),
+                                gimp_item_get_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;
@@ -515,9 +525,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]