From 4ee31d0cac5bf6190b5c7d0c1bba4a23daeee1a8 Mon Sep 17 00:00:00 2001 From: Michael Natterer <mitch@gimp.org> Date: Sat, 31 Mar 2001 14:47:44 +0000 Subject: [PATCH] re-enabled transform undo. Fixes the transform tool crashes. 2001-03-31 Michael Natterer <mitch@gimp.org> * app/undo.c: re-enabled transform undo. Fixes the transform tool crashes. * app/tools/gimptool.[ch]: put tool->ID back because the undo system uses it. Also, a unique tool serial number will be not too bad to have once we have module tools. * app/tools/gimptransformtool.[ch]: changed accordingly. --- ChangeLog | 11 +++++++++ app/core/gimp-transform-region.c | 7 +++--- app/core/gimpdrawable-transform.c | 7 +++--- app/core/gimpimage-undo-push.c | 37 ++++++++++++++----------------- app/tools/gimptool.c | 9 +++----- app/tools/gimptool.h | 2 ++ app/tools/gimptransformtool.c | 7 +++--- app/tools/gimptransformtool.h | 4 ++-- app/undo.c | 37 ++++++++++++++----------------- 9 files changed, 64 insertions(+), 57 deletions(-) diff --git a/ChangeLog b/ChangeLog index b764bb6668..3af8bf44ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2001-03-31 Michael Natterer <mitch@gimp.org> + + * app/undo.c: re-enabled transform undo. Fixes the transform tool + crashes. + + * app/tools/gimptool.[ch]: put tool->ID back because the undo + system uses it. Also, a unique tool serial number will be not too + bad to have once we have module tools. + + * app/tools/gimptransformtool.[ch]: changed accordingly. + 2001-03-31 Michael Natterer <mitch@gimp.org> * app/Makefile.am diff --git a/app/core/gimp-transform-region.c b/app/core/gimp-transform-region.c index 0a8d343d44..cc49328da8 100644 --- a/app/core/gimp-transform-region.c +++ b/app/core/gimp-transform-region.c @@ -664,8 +664,9 @@ gimp_transform_tool_doit (GimpTransformTool *gt_tool, new_tiles, new_layer); /* create and initialize the transform_undo structure */ - tu = g_new (TransformUndo, 1); - tu->tool = gt_tool; + tu = g_new0 (TransformUndo, 1); + tu->tool_ID = tool->ID; + tu->tool_type = GTK_OBJECT (tool)->klass->type; for (i = 0; i < TRAN_INFO_SIZE; i++) tu->trans_info[i] = old_trans_info[i]; @@ -727,7 +728,7 @@ gimp_transform_tool_motion (GimpTool *tool, { GimpTransformTool *tr_tool; - tr_tool = GIMP_TRANSFORM_TOOL(tool); + tr_tool = GIMP_TRANSFORM_TOOL (tool); if (! tr_tool->bpressed) return; diff --git a/app/core/gimpdrawable-transform.c b/app/core/gimpdrawable-transform.c index 0a8d343d44..cc49328da8 100644 --- a/app/core/gimpdrawable-transform.c +++ b/app/core/gimpdrawable-transform.c @@ -664,8 +664,9 @@ gimp_transform_tool_doit (GimpTransformTool *gt_tool, new_tiles, new_layer); /* create and initialize the transform_undo structure */ - tu = g_new (TransformUndo, 1); - tu->tool = gt_tool; + tu = g_new0 (TransformUndo, 1); + tu->tool_ID = tool->ID; + tu->tool_type = GTK_OBJECT (tool)->klass->type; for (i = 0; i < TRAN_INFO_SIZE; i++) tu->trans_info[i] = old_trans_info[i]; @@ -727,7 +728,7 @@ gimp_transform_tool_motion (GimpTool *tool, { GimpTransformTool *tr_tool; - tr_tool = GIMP_TRANSFORM_TOOL(tool); + tr_tool = GIMP_TRANSFORM_TOOL (tool); if (! tr_tool->bpressed) return; diff --git a/app/core/gimpimage-undo-push.c b/app/core/gimpimage-undo-push.c index 7000f1b422..d63895e2e2 100644 --- a/app/core/gimpimage-undo-push.c +++ b/app/core/gimpimage-undo-push.c @@ -49,7 +49,8 @@ #include "tools/gimptool.h" #include "tools/gimpdrawtool.h" #include "tools/gimppainttool.h" -#include "tools/transform_core.h" +#include "tools/gimptransformtool.h" +#include "tools/tool_manager.h" #include "libgimp/gimpparasite.h" @@ -1263,25 +1264,20 @@ undo_pop_transform (GimpImage *gimage, UndoType type, gpointer tu_ptr) { -#ifdef __GNUC__ -#warning very bogus -#endif -#if 0 - TransformCore *tc; - TransformUndo *tu; - TileManager *temp; - gdouble d; - gint i; - + GimpTransformTool *tt; + TransformUndo *tu; + TileManager *temp; + gdouble d; + gint i; /* Can't have ANY tool selected - maybe a plugin running */ if (active_tool == NULL) return TRUE; - tc = (TransformCore *) active_tool->private; + tt = (GimpTransformTool *) active_tool; tu = (TransformUndo *) tu_ptr; - path_transform_do_undo (gimage,tu->path_undo); + path_transform_do_undo (gimage, tu->path_undo); /* only pop if the active tool is the tool that pushed this undo */ if (tu->tool_ID != active_tool->ID) @@ -1291,23 +1287,24 @@ undo_pop_transform (GimpImage *gimage, for (i = 0; i < TRAN_INFO_SIZE; i++) { d = tu->trans_info[i]; - tu->trans_info[i] = tc->trans_info[i]; - tc->trans_info[i] = d; + tu->trans_info[i] = tt->trans_info[i]; + tt->trans_info[i] = d; } /* swap the original buffer--the source buffer for repeated transforms */ temp = tu->original; - tu->original = tc->original; - tc->original = temp; + tu->original = tt->original; + tt->original = temp; /* If we're re-implementing the first transform, reactivate tool */ - if (state == REDO && tc->original) + if (state == REDO && tt->original) { active_tool->state = ACTIVE; - draw_core_resume (tc->core, active_tool); + + gimp_draw_tool_resume (GIMP_DRAW_TOOL (tt)); } -#endif + return TRUE; } diff --git a/app/tools/gimptool.c b/app/tools/gimptool.c index 7ef9152d53..afbf93a70b 100644 --- a/app/tools/gimptool.c +++ b/app/tools/gimptool.c @@ -93,12 +93,7 @@ static guint gimp_tool_signals[LAST_SIGNAL] = { 0 }; static GimpObjectClass *parent_class = NULL; - -#ifdef __GNUC__ -#warning FIXME: check what global_tool_ID was used for -#endif - -/* static gint global_tool_ID = 0; */ +static gint global_tool_ID = 0; GtkType @@ -251,6 +246,8 @@ gimp_tool_class_init (GimpToolClass *klass) static void gimp_tool_init (GimpTool *tool) { + tool->ID = global_tool_ID++; + tool->state = INACTIVE; tool->paused_count = 0; tool->scroll_lock = FALSE; /* Allow scrolling */ diff --git a/app/tools/gimptool.h b/app/tools/gimptool.h index b3704283f8..825b3c717c 100644 --- a/app/tools/gimptool.h +++ b/app/tools/gimptool.h @@ -51,6 +51,8 @@ struct _GimpTool { GimpObject parent_instance; + gint ID; /* unique tool ID */ + ToolState state; /* state of tool activity */ gint paused_count; /* paused control count */ gboolean scroll_lock; /* allow scrolling or not */ diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c index 0a8d343d44..cc49328da8 100644 --- a/app/tools/gimptransformtool.c +++ b/app/tools/gimptransformtool.c @@ -664,8 +664,9 @@ gimp_transform_tool_doit (GimpTransformTool *gt_tool, new_tiles, new_layer); /* create and initialize the transform_undo structure */ - tu = g_new (TransformUndo, 1); - tu->tool = gt_tool; + tu = g_new0 (TransformUndo, 1); + tu->tool_ID = tool->ID; + tu->tool_type = GTK_OBJECT (tool)->klass->type; for (i = 0; i < TRAN_INFO_SIZE; i++) tu->trans_info[i] = old_trans_info[i]; @@ -727,7 +728,7 @@ gimp_transform_tool_motion (GimpTool *tool, { GimpTransformTool *tr_tool; - tr_tool = GIMP_TRANSFORM_TOOL(tool); + tr_tool = GIMP_TRANSFORM_TOOL (tool); if (! tr_tool->bpressed) return; diff --git a/app/tools/gimptransformtool.h b/app/tools/gimptransformtool.h index 3cde867538..9bf506d11f 100644 --- a/app/tools/gimptransformtool.h +++ b/app/tools/gimptransformtool.h @@ -109,8 +109,8 @@ typedef struct _TransformUndo TransformUndo; struct _TransformUndo { - /* Is this the right thing to do? */ - GimpTransformTool *tool; + gint tool_ID; + GtkType tool_type; TranInfo trans_info; TileManager *original; diff --git a/app/undo.c b/app/undo.c index 7000f1b422..d63895e2e2 100644 --- a/app/undo.c +++ b/app/undo.c @@ -49,7 +49,8 @@ #include "tools/gimptool.h" #include "tools/gimpdrawtool.h" #include "tools/gimppainttool.h" -#include "tools/transform_core.h" +#include "tools/gimptransformtool.h" +#include "tools/tool_manager.h" #include "libgimp/gimpparasite.h" @@ -1263,25 +1264,20 @@ undo_pop_transform (GimpImage *gimage, UndoType type, gpointer tu_ptr) { -#ifdef __GNUC__ -#warning very bogus -#endif -#if 0 - TransformCore *tc; - TransformUndo *tu; - TileManager *temp; - gdouble d; - gint i; - + GimpTransformTool *tt; + TransformUndo *tu; + TileManager *temp; + gdouble d; + gint i; /* Can't have ANY tool selected - maybe a plugin running */ if (active_tool == NULL) return TRUE; - tc = (TransformCore *) active_tool->private; + tt = (GimpTransformTool *) active_tool; tu = (TransformUndo *) tu_ptr; - path_transform_do_undo (gimage,tu->path_undo); + path_transform_do_undo (gimage, tu->path_undo); /* only pop if the active tool is the tool that pushed this undo */ if (tu->tool_ID != active_tool->ID) @@ -1291,23 +1287,24 @@ undo_pop_transform (GimpImage *gimage, for (i = 0; i < TRAN_INFO_SIZE; i++) { d = tu->trans_info[i]; - tu->trans_info[i] = tc->trans_info[i]; - tc->trans_info[i] = d; + tu->trans_info[i] = tt->trans_info[i]; + tt->trans_info[i] = d; } /* swap the original buffer--the source buffer for repeated transforms */ temp = tu->original; - tu->original = tc->original; - tc->original = temp; + tu->original = tt->original; + tt->original = temp; /* If we're re-implementing the first transform, reactivate tool */ - if (state == REDO && tc->original) + if (state == REDO && tt->original) { active_tool->state = ACTIVE; - draw_core_resume (tc->core, active_tool); + + gimp_draw_tool_resume (GIMP_DRAW_TOOL (tt)); } -#endif + return TRUE; }