From d1795ac2047de73b7a7d4c9fd2666a8b0b4bd12b Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Mon, 15 Jul 2013 00:41:43 +0200 Subject: [PATCH] Bug 700193 - undoing paint tools doesn't update last_coords properly paint_core->start_coords is in fact the last stroke's endpoint and only used for storing it in GimpPaintCoreUndo, so the last endpoint can be resotred for straight-line painting after an undo. Make the code actually doing that. --- app/paint/gimppaintcore-stroke.c | 13 +++++-------- app/paint/gimppaintcore.c | 4 +++- app/paint/gimppaintcore.h | 2 +- app/tools/gimppainttool.c | 15 ++++++++------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/paint/gimppaintcore-stroke.c b/app/paint/gimppaintcore-stroke.c index 1a6dee7437..7fba0d4a6c 100644 --- a/app/paint/gimppaintcore-stroke.c +++ b/app/paint/gimppaintcore-stroke.c @@ -67,8 +67,7 @@ gimp_paint_core_stroke (GimpPaintCore *core, { gint i; - core->start_coords = strokes[0]; - core->last_coords = strokes[0]; + core->last_coords = strokes[0]; gimp_paint_core_paint (core, drawable, paint_options, GIMP_PAINT_STATE_INIT, 0); @@ -179,9 +178,8 @@ gimp_paint_core_stroke_boundary (GimpPaintCore *core, initialized = TRUE; - core->cur_coords = coords[0]; - core->start_coords = coords[0]; - core->last_coords = coords[0]; + core->cur_coords = coords[0]; + core->last_coords = coords[0]; gimp_paint_core_paint (core, drawable, paint_options, GIMP_PAINT_STATE_INIT, 0); @@ -283,9 +281,8 @@ gimp_paint_core_stroke_vectors (GimpPaintCore *core, { initialized = TRUE; - core->cur_coords = g_array_index (coords, GimpCoords, 0); - core->start_coords = g_array_index (coords, GimpCoords, 0); - core->last_coords = g_array_index (coords, GimpCoords, 0); + core->cur_coords = g_array_index (coords, GimpCoords, 0); + core->last_coords = g_array_index (coords, GimpCoords, 0); gimp_paint_core_paint (core, drawable, paint_options, GIMP_PAINT_STATE_INIT, 0); diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c index c6adeb7013..606800e86c 100644 --- a/app/paint/gimppaintcore.c +++ b/app/paint/gimppaintcore.c @@ -353,6 +353,9 @@ gimp_paint_core_start (GimpPaintCore *core, sizeof (GimpCoords), STROKE_BUFFER_INIT_SIZE); + /* remember the last stroke's endpoint for later undo */ + core->start_coords = core->last_coords; + core->cur_coords = *coords; if (! GIMP_PAINT_CORE_GET_CLASS (core)->start (core, drawable, @@ -677,7 +680,6 @@ gimp_paint_core_get_current_coords (GimpPaintCore *core, g_return_if_fail (coords != NULL); *coords = core->cur_coords; - } void diff --git a/app/paint/gimppaintcore.h b/app/paint/gimppaintcore.h index c935b5c326..b6b7d06b46 100644 --- a/app/paint/gimppaintcore.h +++ b/app/paint/gimppaintcore.h @@ -40,7 +40,7 @@ struct _GimpPaintCore gchar *undo_desc; /* undo description */ - GimpCoords start_coords; /* starting coords (for undo only) */ + GimpCoords start_coords; /* the last stroke's endpoint for undo */ GimpCoords cur_coords; /* current coords */ GimpCoords last_coords; /* last coords */ diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c index 8263356773..ea2595372b 100644 --- a/app/tools/gimppainttool.c +++ b/app/tools/gimppainttool.c @@ -306,13 +306,16 @@ gimp_paint_tool_button_press (GimpTool *tool, if ((display != tool->display) || ! paint_tool->draw_line) { - /* if this is a new image, reinit the core vals */ + /* if this is a new display, resest the "last stroke's endpoint" + * because there is none + */ + if (display != tool->display) + core->start_coords = core->cur_coords; - core->start_coords = core->cur_coords; - core->last_coords = core->cur_coords; + core->last_coords = core->cur_coords; - core->distance = 0.0; - core->pixel_dist = 0.0; + core->distance = 0.0; + core->pixel_dist = 0.0; } else if (paint_tool->draw_line) { @@ -321,8 +324,6 @@ gimp_paint_tool_button_press (GimpTool *tool, /* If shift is down and this is not the first paint * stroke, then draw a line from the last coords to the pointer */ - core->start_coords = core->last_coords; - gimp_paint_core_round_line (core, paint_options, constrain); }