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.
This commit is contained in:
Ell 2018-09-26 02:06:40 -04:00
parent 53964dcb92
commit a5baba5539
1 changed files with 27 additions and 6 deletions

View File

@ -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_draw_tool_resume (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));
}
else
{
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
}
return TRUE;
}
return FALSE;