[gimp/gimp-2-8] Bug 700193 - undoing paint tools doesn't update last_coords properly



commit 60bf4e367d0357df8eef5dc034f997167aee4d69
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jul 15 00:41:43 2013 +0200

    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.
    
    (cherry picked from commit d1795ac2047de73b7a7d4c9fd2666a8b0b4bd12b)

 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 7c1a8f3..af068bc 100644
--- a/app/paint/gimppaintcore-stroke.c
+++ b/app/paint/gimppaintcore-stroke.c
@@ -68,8 +68,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 c6d3183..7c1c5c7 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -370,6 +370,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,
@@ -636,7 +639,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 970edb8..a46fbe5 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 7810835..9c52335 100644
--- a/app/tools/gimppainttool.c
+++ b/app/tools/gimppainttool.c
@@ -300,13 +300,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)
     {
@@ -315,8 +318,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);
     }
 


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