[gimp] Bug 767935: Foreground Select Freezes Gimp if accidentally...
- From: Massimo Valentini <mvalentini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 767935: Foreground Select Freezes Gimp if accidentally...
- Date: Mon, 27 Jun 2016 15:33:40 +0000 (UTC)
commit ee860a0c30a95fac86f73781e248c94eab612250
Author: Massimo Valentini <mvalentini src gnome org>
Date: Sat Jun 25 11:12:13 2016 +0200
Bug 767935: Foreground Select Freezes Gimp if accidentally...
...clicking outside canvas
app/tools/gimpforegroundselecttool.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/app/tools/gimpforegroundselecttool.c b/app/tools/gimpforegroundselecttool.c
index 30efe83..4e6ebd7 100644
--- a/app/tools/gimpforegroundselecttool.c
+++ b/app/tools/gimpforegroundselecttool.c
@@ -1115,6 +1115,12 @@ gimp_foreground_select_tool_stroke_paint (GimpForegroundSelectTool *fg_select)
undo = gimp_foreground_select_undo_new (fg_select->trimap,
fg_select->stroke,
options->draw_mode, width);
+ if (! undo)
+ {
+ g_array_free (fg_select->stroke, TRUE);
+ fg_select->stroke = NULL;
+ return;
+ }
fg_select->undo_stack = g_list_prepend (fg_select->undo_stack, undo);
@@ -1235,7 +1241,7 @@ gimp_foreground_select_undo_new (GeglBuffer *trimap,
gint stroke_width)
{
- StrokeUndo *undo = g_slice_new0 (StrokeUndo);
+ StrokeUndo *undo;
gint x1, y1, x2, y2;
gint width, height;
gint i;
@@ -1255,10 +1261,10 @@ gimp_foreground_select_undo_new (GeglBuffer *trimap,
y2 = MAX (y2, ceil (point->y));
}
- x1 -= stroke_width;
- y1 -= stroke_width;
- x2 += stroke_width;
- y2 += stroke_width;
+ x1 -= (stroke_width + 1) / 2;
+ y1 -= (stroke_width + 1) / 2;
+ x2 += (stroke_width + 1) / 2;
+ y2 += (stroke_width + 1) / 2;
x1 = MAX (x1, 0);
y1 = MAX (y1, 0);
@@ -1268,6 +1274,10 @@ gimp_foreground_select_undo_new (GeglBuffer *trimap,
width = x2 - x1;
height = y2 - y1;
+ if (width <= 0 || height <= 0)
+ return NULL;
+
+ undo = g_slice_new0 (StrokeUndo);
undo->saved_trimap = gegl_buffer_new (GEGL_RECTANGLE (0, 0, width, height),
gegl_buffer_get_format (trimap));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]