[gimp] Issue #2272 - Crash when using the intelligent-scissors tool ...



commit a5baba55396a90f49701966138bb50df144508ed
Author: Ell <ell_se yahoo com>
Date:   Wed Sep 26 02:06:40 2018 -0400

    Issue #2272 - Crash when using the intelligent-scissors tool ...
    
    ... after erasing all points
    
    When erasing the last remaining point in the iscissors tool, halt
    the tool, rather than leaving the tool active with an empty curve,
    which it is not prepared to handle, and which results in a segfault
    once trying to add a new point.
    
    Additionally, when erasing the last remaining segment (i.e., the
    two last remaining points), don't erase the entire segment (i.e.,
    both points), but rather convert the segment to its initial point,
    so that, in effect, we only erase the last point of the segment.

 app/tools/gimpiscissorstool.c | 33 +++++++++++++++++++++++++++------
 1 file changed, 27 insertions(+), 6 deletions(-)
---
diff --git a/app/tools/gimpiscissorstool.c b/app/tools/gimpiscissorstool.c
index 67fb62f7ee..98c3b5a61c 100644
--- a/app/tools/gimpiscissorstool.c
+++ b/app/tools/gimpiscissorstool.c
@@ -1075,14 +1075,35 @@ gimp_iscissors_tool_key_press (GimpTool    *tool,
       if (! iscissors->curve->closed &&
           g_queue_peek_tail (iscissors->curve->segments))
         {
-          gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
+          ISegment *segment = g_queue_peek_tail (iscissors->curve->segments);
 
-          gimp_iscissors_tool_push_undo (iscissors);
-          icurve_delete_segment (iscissors->curve,
-                                 g_queue_peek_tail (iscissors->curve->segments));
-          gimp_iscissors_tool_free_redo (iscissors);
+          if (g_queue_get_length (iscissors->curve->segments) > 1)
+            {
+              gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
+
+              gimp_iscissors_tool_push_undo (iscissors);
+              icurve_delete_segment (iscissors->curve, segment);
+              gimp_iscissors_tool_free_redo (iscissors);
+
+              gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
+            }
+          else if (segment->x2 != segment->x1 || segment->y2 != segment->y1)
+            {
+              gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
+
+              gimp_iscissors_tool_push_undo (iscissors);
+              segment->x2 = segment->x1;
+              segment->y2 = segment->y1;
+              g_ptr_array_remove_range (segment->points,
+                                        0, segment->points->len);
+              gimp_iscissors_tool_free_redo (iscissors);
 
-          gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
+              gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
+            }
+          else
+            {
+              gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
+            }
           return TRUE;
         }
       return FALSE;


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