[gimp] plugged memory leaks



commit 39368a410dc69fe952a6fe7afb909a9919e4ecdd
Author: Massimo Valentini <mvalentini src gnome org>
Date:   Tue Feb 7 14:06:12 2012 +0100

    plugged memory leaks

 app/actions/windows-actions.c          |    1 +
 app/core/gimpimage-convert.c           |    1 +
 app/core/gimpimage-merge.c             |    7 +++----
 app/core/gimpitem-exclusive.c          |    2 ++
 app/core/gimpstrokeoptions.c           |    6 ++++++
 app/dialogs/about-dialog.c             |   22 ++++++++++------------
 app/dialogs/module-dialog.c            |    1 +
 app/display/gimpcanvaspolygon.c        |    3 ++-
 app/display/gimpdisplayshell-expose.c  |    3 ++-
 app/gui/gimpuiconfigurer.c             |    1 +
 app/paint/gimppaintcore.c              |    6 ++++++
 app/pdb/gimpprocedure.c                |    1 +
 app/pdb/vectors-cmds.c                 |    3 +++
 app/text/gimptextlayer-xcf.c           |    3 +++
 app/text/gimptextlayout.c              |    1 +
 app/tools/gimpdrawtool.c               |    2 +-
 app/tools/gimpvectortool.c             |   10 ++++++++--
 app/vectors/gimpvectors-import.c       |    2 +-
 app/vectors/gimpvectors.c              |    2 +-
 app/widgets/gimpcontrollerlist.c       |    2 ++
 app/widgets/gimpdeviceinfoeditor.c     |    1 +
 app/widgets/gimptagentry.c             |    1 +
 app/widgets/gimptextbuffer-serialize.c |    1 +
 app/widgets/gimptextstyleeditor.c      |    1 +
 app/xcf/xcf-load.c                     |   11 ++++++++++-
 libgimpwidgets/gimpnumberpairentry.c   |    1 +
 tools/pdbgen/pdb/vectors.pdb           |    3 +++
 27 files changed, 74 insertions(+), 24 deletions(-)
---
diff --git a/app/actions/windows-actions.c b/app/actions/windows-actions.c
index 41eb2c8..7adf621 100644
--- a/app/actions/windows-actions.c
+++ b/app/actions/windows-actions.c
@@ -357,6 +357,7 @@ windows_actions_update_display_accels (GimpActionGroup *group)
 
       action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
                                             action_name);
+      g_free (action_name);
 
       if (action)
         {
diff --git a/app/core/gimpimage-convert.c b/app/core/gimpimage-convert.c
index 0c06dc1..b3cfae2 100644
--- a/app/core/gimpimage-convert.c
+++ b/app/core/gimpimage-convert.c
@@ -2285,6 +2285,7 @@ select_colors_rgb (QuantizeObj *quantobj,
     {
       compute_color_rgb (quantobj, histogram, &boxlist[i], i);
     }
+  g_free (boxlist);
 }
 
 
diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c
index 46cfa46..28eed3a 100644
--- a/app/core/gimpimage-merge.c
+++ b/app/core/gimpimage-merge.c
@@ -419,6 +419,7 @@ gimp_image_merge_layers (GimpImage     *image,
 {
   GList            *list;
   GSList           *reverse_list = NULL;
+  GSList           *layers;
   PixelRegion       src1PR, src2PR, maskPR;
   PixelRegion      *mask;
   GimpLayer        *merge_layer;
@@ -600,14 +601,14 @@ gimp_image_merge_layers (GimpImage     *image,
   gimp_item_set_parasites (GIMP_ITEM (merge_layer), parasites);
   g_object_unref (parasites);
 
-  while (reverse_list)
+  for (layers = reverse_list; layers; layers = g_slist_next (layers))
     {
       CombinationMode      operation;
       GimpLayerModeEffects mode;
       gint                 x3, y3, x4, y4;
       gboolean             active[MAX_CHANNELS] = { TRUE, TRUE, TRUE, TRUE };
 
-      layer = reverse_list->data;
+      layer = layers->data;
 
       /*  determine what sort of operation is being attempted and
        *  if it's actually legal...
@@ -679,8 +680,6 @@ gimp_image_merge_layers (GimpImage     *image,
                        operation);
 
       gimp_image_remove_layer (image, layer, TRUE, NULL);
-
-      reverse_list = g_slist_next (reverse_list);
     }
 
   g_slist_free (reverse_list);
diff --git a/app/core/gimpitem-exclusive.c b/app/core/gimpitem-exclusive.c
index 15ce52b..aa504b0 100644
--- a/app/core/gimpitem-exclusive.c
+++ b/app/core/gimpitem-exclusive.c
@@ -121,6 +121,8 @@ gimp_item_toggle_exclusive_visible (GimpItem    *item,
       g_list_free (on);
       g_list_free (off);
     }
+
+  g_list_free (ancestry);
 }
 
 
diff --git a/app/core/gimpstrokeoptions.c b/app/core/gimpstrokeoptions.c
index f7fce48..832e99a 100644
--- a/app/core/gimpstrokeoptions.c
+++ b/app/core/gimpstrokeoptions.c
@@ -236,6 +236,12 @@ gimp_stroke_options_finalize (GObject *object)
 {
   GimpStrokeOptionsPrivate *private = GET_PRIVATE (object);
 
+  if (private->dash_info)
+    {
+      gimp_dash_pattern_free (private->dash_info);
+      private->dash_info = NULL;
+    }
+
   if (private->paint_options)
     {
       g_object_unref (private->paint_options);
diff --git a/app/dialogs/about-dialog.c b/app/dialogs/about-dialog.c
index ce07c85..a34d062 100644
--- a/app/dialogs/about-dialog.c
+++ b/app/dialogs/about-dialog.c
@@ -87,11 +87,11 @@ static void        about_dialog_add_message   (GtkWidget       *vbox);
 GtkWidget *
 about_dialog_create (GimpContext *context)
 {
-  static GimpAboutDialog *dialog = NULL;
+  static GimpAboutDialog dialog;
 
   g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
 
-  if (! dialog)
+  if (! dialog.dialog)
     {
       GtkWidget *widget;
       GtkWidget *container;
@@ -99,9 +99,7 @@ about_dialog_create (GimpContext *context)
       GList     *children;
       gchar     *copyright;
 
-      dialog = g_new0 (GimpAboutDialog, 1);
-
-      dialog->n_authors = G_N_ELEMENTS (authors) - 1;
+      dialog.n_authors = G_N_ELEMENTS (authors) - 1;
 
       pixbuf = about_dialog_load_logo ();
 
@@ -133,9 +131,9 @@ about_dialog_create (GimpContext *context)
 
       g_free (copyright);
 
-      dialog->dialog = widget;
+      dialog.dialog = widget;
 
-      g_object_add_weak_pointer (G_OBJECT (widget), (gpointer) &dialog);
+      g_object_add_weak_pointer (G_OBJECT (widget), (gpointer) &dialog.dialog);
 
       g_signal_connect (widget, "response",
                         G_CALLBACK (gtk_widget_destroy),
@@ -143,10 +141,10 @@ about_dialog_create (GimpContext *context)
 
       g_signal_connect (widget, "map",
                         G_CALLBACK (about_dialog_map),
-                        dialog);
+                        &dialog);
       g_signal_connect (widget, "unmap",
                         G_CALLBACK (about_dialog_unmap),
-                        dialog);
+                        &dialog);
 
       /*  kids, don't try this at home!  */
       container = gtk_dialog_get_content_area (GTK_DIALOG (widget));
@@ -154,7 +152,7 @@ about_dialog_create (GimpContext *context)
 
       if (GTK_IS_BOX (children->data))
         {
-          about_dialog_add_animation (children->data, dialog);
+          about_dialog_add_animation (children->data, &dialog);
           about_dialog_add_message (children->data);
         }
       else
@@ -163,9 +161,9 @@ about_dialog_create (GimpContext *context)
       g_list_free (children);
     }
 
-  gtk_window_present (GTK_WINDOW (dialog->dialog));
+  gtk_window_present (GTK_WINDOW (dialog.dialog));
 
-  return dialog->dialog;
+  return dialog.dialog;
 }
 
 static void
diff --git a/app/dialogs/module-dialog.c b/app/dialogs/module-dialog.c
index ba66938..c4e494d 100644
--- a/app/dialogs/module-dialog.c
+++ b/app/dialogs/module-dialog.c
@@ -473,6 +473,7 @@ dialog_info_update (GimpModuleDB *db,
   for (i = 0; i < N_INFOS; i++)
     gtk_label_set_text (GTK_LABEL (dialog->label[i]),
                         text[i] ? text[i] : "--");
+  g_free (location);
 
   /* Show errors */
   show_error = (module->state == GIMP_MODULE_STATE_ERROR &&
diff --git a/app/display/gimpcanvaspolygon.c b/app/display/gimpcanvaspolygon.c
index 4165637..022150d 100644
--- a/app/display/gimpcanvaspolygon.c
+++ b/app/display/gimpcanvaspolygon.c
@@ -337,7 +337,7 @@ gimp_canvas_polygon_new_from_coords (GimpDisplayShell *shell,
     }
 
   array = gimp_array_new ((const guint8 *) points,
-                          n_coords * sizeof (GimpVector2), FALSE);
+                          n_coords * sizeof (GimpVector2), TRUE);
 
   item = g_object_new (GIMP_TYPE_CANVAS_POLYGON,
                        "shell",  shell,
@@ -346,6 +346,7 @@ gimp_canvas_polygon_new_from_coords (GimpDisplayShell *shell,
                        NULL);
 
   gimp_array_free (array);
+  g_free (points);
 
   return item;
 }
diff --git a/app/display/gimpdisplayshell-expose.c b/app/display/gimpdisplayshell-expose.c
index f68f6f2..b60ef13 100644
--- a/app/display/gimpdisplayshell-expose.c
+++ b/app/display/gimpdisplayshell-expose.c
@@ -41,7 +41,7 @@ void
 gimp_display_shell_expose_region (GimpDisplayShell *shell,
                                   cairo_region_t   *region)
 {
-  GdkRegion *gdk_region = gdk_region_new ();
+  GdkRegion *gdk_region;
   gint       n_rectangles;
   gint       i;
 
@@ -51,6 +51,7 @@ gimp_display_shell_expose_region (GimpDisplayShell *shell,
   if (! gtk_widget_get_realized (shell->canvas))
     return;
 
+  gdk_region = gdk_region_new ();
   n_rectangles = cairo_region_num_rectangles (region);
 
   for (i = 0; i < n_rectangles; i++)
diff --git a/app/gui/gimpuiconfigurer.c b/app/gui/gimpuiconfigurer.c
index fcacd1a..6b3bafa 100644
--- a/app/gui/gimpuiconfigurer.c
+++ b/app/gui/gimpuiconfigurer.c
@@ -265,6 +265,7 @@ gimp_ui_configurer_move_docks_to_columns (GimpUIConfigurer *ui_configurer,
           g_list_free (docks);
         }
     }
+  g_list_free (dialogs);
 }
 
 /**
diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c
index 18892b8..c6d3183 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -178,6 +178,12 @@ gimp_paint_core_finalize (GObject *object)
   g_free (core->undo_desc);
   core->undo_desc = NULL;
 
+  if (core->stroke_buffer)
+    {
+      g_array_free (core->stroke_buffer, TRUE);
+      core->stroke_buffer = NULL;
+    }
+
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
diff --git a/app/pdb/gimpprocedure.c b/app/pdb/gimpprocedure.c
index d249711..aa6e4c1 100644
--- a/app/pdb/gimpprocedure.c
+++ b/app/pdb/gimpprocedure.c
@@ -764,6 +764,7 @@ gimp_procedure_validate_args (GimpProcedure  *procedure,
                     }
                 }
 
+              g_value_unset (&string_value);
               return FALSE;
             }
 
diff --git a/app/pdb/vectors-cmds.c b/app/pdb/vectors-cmds.c
index e54d9fb..a566da4 100644
--- a/app/pdb/vectors-cmds.c
+++ b/app/pdb/vectors-cmds.c
@@ -695,6 +695,7 @@ vectors_stroke_new_from_points_invoker (GimpProcedure      *procedure,
                                                   vectors);
 
               gimp_vectors_stroke_add (vectors, stroke);
+              g_object_unref (stroke);
 
               stroke_id = gimp_stroke_get_ID (stroke);
 
@@ -817,6 +818,7 @@ vectors_bezier_stroke_new_moveto_invoker (GimpProcedure      *procedure,
                                               vectors);
 
           gimp_vectors_stroke_add (vectors, stroke);
+          g_object_unref (stroke);
 
           stroke_id = gimp_stroke_get_ID (stroke);
         }
@@ -1036,6 +1038,7 @@ vectors_bezier_stroke_new_ellipse_invoker (GimpProcedure      *procedure,
                                               vectors);
 
           gimp_vectors_stroke_add (vectors, stroke);
+          g_object_unref (stroke);
 
           stroke_id = gimp_stroke_get_ID (stroke);
         }
diff --git a/app/text/gimptextlayer-xcf.c b/app/text/gimptextlayer-xcf.c
index 15a3415..f49c18a 100644
--- a/app/text/gimptextlayer-xcf.c
+++ b/app/text/gimptextlayer-xcf.c
@@ -22,6 +22,7 @@
 
 #include <gegl.h>
 
+#include "libgimpbase/gimpbase.h"
 #include "text-types.h"
 
 #include "core/gimp.h"
@@ -125,6 +126,8 @@ gimp_text_layer_xcf_save_prepare (GimpTextLayer *layer)
        *  while the text layer is saved to XCF.
        */
       gimp_item_parasite_attach (GIMP_ITEM (layer), parasite, FALSE);
+
+      gimp_parasite_free (parasite);
     }
 }
 
diff --git a/app/text/gimptextlayout.c b/app/text/gimptextlayout.c
index 299d19b..06161e5 100644
--- a/app/text/gimptextlayout.c
+++ b/app/text/gimptextlayout.c
@@ -550,6 +550,7 @@ gimp_text_layout_set_markup (GimpTextLayout *layout)
   g_free (close_tag);
 
   pango_layout_set_markup (layout->layout, markup, -1);
+  g_free (markup);
 }
 
 static void
diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c
index 8eefd73..531e46c 100644
--- a/app/tools/gimpdrawtool.c
+++ b/app/tools/gimpdrawtool.c
@@ -1049,7 +1049,7 @@ gimp_draw_tool_on_vectors_handle (GimpDrawTool      *draw_tool,
 
   while ((stroke = gimp_vectors_stroke_get_next (vectors, stroke)))
     {
-      GList *anchor_list = gimp_stroke_get_draw_anchors (stroke);
+      GList *anchor_list;
       GList *list;
 
       anchor_list = g_list_concat (gimp_stroke_get_draw_anchors (stroke),
diff --git a/app/tools/gimpvectortool.c b/app/tools/gimpvectortool.c
index 27ccbaf..77d58de 100644
--- a/app/tools/gimpvectortool.c
+++ b/app/tools/gimpvectortool.c
@@ -341,6 +341,7 @@ gimp_vector_tool_button_press (GimpTool            *tool,
 
       vector_tool->cur_stroke = gimp_bezier_stroke_new ();
       gimp_vectors_stroke_add (vector_tool->vectors, vector_tool->cur_stroke);
+      g_object_unref (vector_tool->cur_stroke);
 
       vector_tool->undo_motion = TRUE;
 
@@ -610,7 +611,6 @@ gimp_vector_tool_button_press (GimpTool            *tool,
 
 
   /* deleting a segment (opening up a stroke) */
-
   if (vector_tool->function == VECTORS_DELETE_SEGMENT &&
       gimp_vector_tool_check_writable (vector_tool))
     {
@@ -621,7 +621,10 @@ gimp_vector_tool_button_press (GimpTool            *tool,
       new_stroke = gimp_stroke_open (vector_tool->cur_stroke,
                                      vector_tool->cur_anchor);
       if (new_stroke)
-        gimp_vectors_stroke_add (vector_tool->vectors, new_stroke);
+        {
+          gimp_vectors_stroke_add (vector_tool->vectors, new_stroke);
+          g_object_unref (new_stroke);
+        }
 
       vector_tool->undo_motion = TRUE;
       vector_tool->cur_stroke = NULL;
@@ -1881,6 +1884,7 @@ gimp_vector_tool_verify_state (GimpVectorTool *vector_tool)
             }
         }
 
+      g_list_free (anchors);
       anchors = gimp_stroke_get_draw_controls (cur_stroke);
 
       for (list = anchors; list; list = g_list_next (list))
@@ -1890,6 +1894,8 @@ gimp_vector_tool_verify_state (GimpVectorTool *vector_tool)
           if (cur_anchor == vector_tool->cur_anchor)
             cur_anchor_valid = TRUE;
         }
+
+      g_list_free (anchors);
     }
 
   if (! cur_stroke_valid)
diff --git a/app/vectors/gimpvectors-import.c b/app/vectors/gimpvectors-import.c
index 3f76553..6dd156d 100644
--- a/app/vectors/gimpvectors-import.c
+++ b/app/vectors/gimpvectors-import.c
@@ -356,7 +356,7 @@ gimp_vectors_import (GimpImage    *image,
               if (! merge)
                 gimp_vectors_thaw (vectors);
 
-              g_list_free (path->strokes);
+              g_list_free_full (path->strokes, g_object_unref);
               path->strokes = NULL;
             }
 
diff --git a/app/vectors/gimpvectors.c b/app/vectors/gimpvectors.c
index 842c313..26f2c23 100644
--- a/app/vectors/gimpvectors.c
+++ b/app/vectors/gimpvectors.c
@@ -1170,8 +1170,8 @@ gimp_vectors_real_make_bezier (const GimpVectors *vectors)
     {
       ret_bezdesc = gimp_bezier_desc_new ((cairo_path_data_t *) cmd_array->data,
                                           cmd_array->len);
-      g_array_free (cmd_array, FALSE);
     }
+  g_array_free (cmd_array, FALSE);
 
   return ret_bezdesc;
 }
diff --git a/app/widgets/gimpcontrollerlist.c b/app/widgets/gimpcontrollerlist.c
index 5faeca9..67deed7 100644
--- a/app/widgets/gimpcontrollerlist.c
+++ b/app/widgets/gimpcontrollerlist.c
@@ -313,6 +313,8 @@ gimp_controller_list_init (GimpControllerList *list)
   gtk_widget_set_sensitive (list->edit_button, FALSE);
   gtk_widget_set_sensitive (list->up_button,   FALSE);
   gtk_widget_set_sensitive (list->down_button, FALSE);
+
+  g_free (controller_types);
 }
 
 static void
diff --git a/app/widgets/gimpdeviceinfoeditor.c b/app/widgets/gimpdeviceinfoeditor.c
index 15c8fec..391994c 100644
--- a/app/widgets/gimpdeviceinfoeditor.c
+++ b/app/widgets/gimpdeviceinfoeditor.c
@@ -487,6 +487,7 @@ gimp_device_info_editor_constructed (GObject *object)
           label = gtk_label_new (string);
           gtk_container_add (GTK_CONTAINER (frame), label);
           gtk_widget_show (label);
+          g_free (string);
         }
     }
 }
diff --git a/app/widgets/gimptagentry.c b/app/widgets/gimptagentry.c
index a913147..e98e5b3 100644
--- a/app/widgets/gimptagentry.c
+++ b/app/widgets/gimptagentry.c
@@ -875,6 +875,7 @@ gimp_tag_entry_parse_tags (GimpTagEntry *entry)
     }
   parsed_tags[length] = NULL;
 
+  g_list_free (tag_list);
   return parsed_tags;
 }
 
diff --git a/app/widgets/gimptextbuffer-serialize.c b/app/widgets/gimptextbuffer-serialize.c
index d82fe5c..fd83002 100644
--- a/app/widgets/gimptextbuffer-serialize.c
+++ b/app/widgets/gimptextbuffer-serialize.c
@@ -236,6 +236,7 @@ gimp_text_buffer_serialize (GtkTextBuffer     *register_buffer,
     }
   while (! gtk_text_iter_equal (&iter, end));
 
+  g_slist_free (tag_list);
   /* Close any open tags */
   for (tag_list = active_tags; tag_list; tag_list = tag_list->next)
     close_tag (GIMP_TEXT_BUFFER (register_buffer), string, tag_list->data);
diff --git a/app/widgets/gimptextstyleeditor.c b/app/widgets/gimptextstyleeditor.c
index 708988c..c76aefc 100644
--- a/app/widgets/gimptextstyleeditor.c
+++ b/app/widgets/gimptextstyleeditor.c
@@ -424,6 +424,7 @@ gimp_text_style_editor_finalize (GObject *object)
       editor->fonts = NULL;
     }
 
+  g_list_free (editor->toggles);
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index 2fa05e8..be9fb2d 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -241,6 +241,8 @@ xcf_load_image (Gimp     *gimp,
                                                      NULL));
 
               container = gimp_viewable_get_children (GIMP_VIEWABLE (parent));
+
+              g_list_free (item_path);
             }
           else
             {
@@ -1727,7 +1729,10 @@ xcf_load_old_path (XcfInfo   *info,
 
   /* skip empty compatibility paths */
   if (num_points == 0)
-    return FALSE;
+    {
+      g_free (name);
+      return FALSE;
+    }
 
   points = g_new0 (GimpVectorsCompatPoint, num_points);
 
@@ -1856,6 +1861,7 @@ xcf_load_vector (XcfInfo   *info,
 #endif
 
   vectors = gimp_vectors_new (image, name);
+  g_free (name);
 
   gimp_item_set_visible (GIMP_ITEM (vectors), visible, FALSE);
   gimp_item_set_linked (GIMP_ITEM (vectors), linked, FALSE);
@@ -1957,6 +1963,9 @@ xcf_load_vector (XcfInfo   *info,
                              NULL);
 
       gimp_vectors_stroke_add (vectors, stroke);
+
+      g_object_unref (stroke);
+      g_value_array_free (control_points);
     }
 
   gimp_image_add_vectors (image, vectors,
diff --git a/libgimpwidgets/gimpnumberpairentry.c b/libgimpwidgets/gimpnumberpairentry.c
index f085b96..7bed2da 100644
--- a/libgimpwidgets/gimpnumberpairentry.c
+++ b/libgimpwidgets/gimpnumberpairentry.c
@@ -333,6 +333,7 @@ gimp_number_pair_entry_finalize (GObject *object)
       priv->num_separators = 0;
     }
 
+  g_free (priv->default_text);
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
diff --git a/tools/pdbgen/pdb/vectors.pdb b/tools/pdbgen/pdb/vectors.pdb
index 737acbc..f85a553 100644
--- a/tools/pdbgen/pdb/vectors.pdb
+++ b/tools/pdbgen/pdb/vectors.pdb
@@ -741,6 +741,7 @@ HELP
                                               vectors);
 
 	  gimp_vectors_stroke_add (vectors, stroke);
+	  g_object_unref (stroke);
 
 	  stroke_id = gimp_stroke_get_ID (stroke);
 
@@ -797,6 +798,7 @@ HELP
                                           vectors);
 
       gimp_vectors_stroke_add (vectors, stroke);
+      g_object_unref (stroke);
 
       stroke_id = gimp_stroke_get_ID (stroke);
     }
@@ -1021,6 +1023,7 @@ HELP
                                           vectors);
 
       gimp_vectors_stroke_add (vectors, stroke);
+      g_object_unref (stroke);
 
       stroke_id = gimp_stroke_get_ID (stroke);
     }



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