[gimp/gimp-2-8] app: free GimpEditSelectionTool's stuff in finalize()



commit 6b2ebecfc7e345c176f5a2768b2d6dfba9a7f546
Author: Michael Natterer <mitch gimp org>
Date:   Fri Jul 3 12:26:32 2015 +0200

    app: free GimpEditSelectionTool's stuff in finalize()
    
    (cherry picked from commit 7d220a56e0ff9513b5e5f757a90d8034ee1d9a5a)

 app/tools/gimpeditselectiontool.c |   53 +++++++++++++++++++++++++++----------
 1 files changed, 39 insertions(+), 14 deletions(-)
---
diff --git a/app/tools/gimpeditselectiontool.c b/app/tools/gimpeditselectiontool.c
index a76171d..3ea49ac 100644
--- a/app/tools/gimpeditselectiontool.c
+++ b/app/tools/gimpeditselectiontool.c
@@ -106,6 +106,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,
@@ -137,9 +139,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;
@@ -158,6 +163,40 @@ gimp_edit_selection_tool_init (GimpEditSelectionTool *edit_select)
 }
 
 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,
                                       gdouble                y)
@@ -534,20 +573,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))
     {


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