From 7d220a56e0ff9513b5e5f757a90d8034ee1d9a5a Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Fri, 3 Jul 2015 12:26:32 +0200 Subject: [PATCH] app: free GimpEditSelectionTool's stuff in finalize() --- app/tools/gimpeditselectiontool.c | 53 +++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/app/tools/gimpeditselectiontool.c b/app/tools/gimpeditselectiontool.c index 3992058340..5c45d8f7a9 100644 --- a/app/tools/gimpeditselectiontool.c +++ b/app/tools/gimpeditselectiontool.c @@ -105,6 +105,8 @@ struct _GimpEditSelectionToolClass }; +static void gimp_edit_selection_tool_finalize (GObject *object); + static void gimp_edit_selection_tool_button_release (GimpTool *tool, const GimpCoords *coords, guint32 time, @@ -136,9 +138,12 @@ G_DEFINE_TYPE (GimpEditSelectionTool, gimp_edit_selection_tool, static void gimp_edit_selection_tool_class_init (GimpEditSelectionToolClass *klass) { + GObjectClass *object_class = G_OBJECT_CLASS (klass); GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass); GimpDrawToolClass *draw_class = GIMP_DRAW_TOOL_CLASS (klass); + object_class->finalize = gimp_edit_selection_tool_finalize; + tool_class->button_release = gimp_edit_selection_tool_button_release; tool_class->motion = gimp_edit_selection_tool_motion; tool_class->active_modifier_key = gimp_edit_selection_tool_active_modifier_key; @@ -152,6 +157,40 @@ gimp_edit_selection_tool_init (GimpEditSelectionTool *edit_select) edit_select->first_move = TRUE; } +static void +gimp_edit_selection_tool_finalize (GObject *object) +{ + GimpEditSelectionTool *edit_select = GIMP_EDIT_SELECTION_TOOL (object); + + if (edit_select->segs_in) + { + g_free (edit_select->segs_in); + edit_select->segs_in = NULL; + edit_select->num_segs_in = 0; + } + + if (edit_select->segs_out) + { + g_free (edit_select->segs_out); + edit_select->segs_out = NULL; + edit_select->num_segs_out = 0; + } + + if (edit_select->live_items) + { + g_list_free (edit_select->live_items); + edit_select->live_items = NULL; + } + + if (edit_select->delayed_items) + { + g_list_free (edit_select->delayed_items); + edit_select->delayed_items = NULL; + } + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + static void gimp_edit_selection_tool_calc_coords (GimpEditSelectionTool *edit_select, gdouble x, @@ -529,20 +568,6 @@ gimp_edit_selection_tool_button_release (GimpTool *tool, gimp_image_flush (image); - g_free (edit_select->segs_in); - g_free (edit_select->segs_out); - - edit_select->segs_in = NULL; - edit_select->segs_out = NULL; - edit_select->num_segs_in = 0; - edit_select->num_segs_out = 0; - - g_list_free (edit_select->live_items); - g_list_free (edit_select->delayed_items); - - edit_select->live_items = NULL; - edit_select->delayed_items = NULL; - if (edit_select->propagate_release && tool_manager_get_active (display->gimp)) {