plugged memory leaks

This commit is contained in:
Massimo Valentini
2012-02-07 14:06:12 +01:00
parent 73a3b56ec9
commit 39368a410d
27 changed files with 74 additions and 24 deletions

View File

@ -357,6 +357,7 @@ windows_actions_update_display_accels (GimpActionGroup *group)
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
action_name); action_name);
g_free (action_name);
if (action) if (action)
{ {

View File

@ -2285,6 +2285,7 @@ select_colors_rgb (QuantizeObj *quantobj,
{ {
compute_color_rgb (quantobj, histogram, &boxlist[i], i); compute_color_rgb (quantobj, histogram, &boxlist[i], i);
} }
g_free (boxlist);
} }

View File

@ -419,6 +419,7 @@ gimp_image_merge_layers (GimpImage *image,
{ {
GList *list; GList *list;
GSList *reverse_list = NULL; GSList *reverse_list = NULL;
GSList *layers;
PixelRegion src1PR, src2PR, maskPR; PixelRegion src1PR, src2PR, maskPR;
PixelRegion *mask; PixelRegion *mask;
GimpLayer *merge_layer; GimpLayer *merge_layer;
@ -600,14 +601,14 @@ gimp_image_merge_layers (GimpImage *image,
gimp_item_set_parasites (GIMP_ITEM (merge_layer), parasites); gimp_item_set_parasites (GIMP_ITEM (merge_layer), parasites);
g_object_unref (parasites); g_object_unref (parasites);
while (reverse_list) for (layers = reverse_list; layers; layers = g_slist_next (layers))
{ {
CombinationMode operation; CombinationMode operation;
GimpLayerModeEffects mode; GimpLayerModeEffects mode;
gint x3, y3, x4, y4; gint x3, y3, x4, y4;
gboolean active[MAX_CHANNELS] = { TRUE, TRUE, TRUE, TRUE }; gboolean active[MAX_CHANNELS] = { TRUE, TRUE, TRUE, TRUE };
layer = reverse_list->data; layer = layers->data;
/* determine what sort of operation is being attempted and /* determine what sort of operation is being attempted and
* if it's actually legal... * if it's actually legal...
@ -679,8 +680,6 @@ gimp_image_merge_layers (GimpImage *image,
operation); operation);
gimp_image_remove_layer (image, layer, TRUE, NULL); gimp_image_remove_layer (image, layer, TRUE, NULL);
reverse_list = g_slist_next (reverse_list);
} }
g_slist_free (reverse_list); g_slist_free (reverse_list);

View File

@ -121,6 +121,8 @@ gimp_item_toggle_exclusive_visible (GimpItem *item,
g_list_free (on); g_list_free (on);
g_list_free (off); g_list_free (off);
} }
g_list_free (ancestry);
} }

View File

@ -236,6 +236,12 @@ gimp_stroke_options_finalize (GObject *object)
{ {
GimpStrokeOptionsPrivate *private = GET_PRIVATE (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) if (private->paint_options)
{ {
g_object_unref (private->paint_options); g_object_unref (private->paint_options);

View File

@ -87,11 +87,11 @@ static void about_dialog_add_message (GtkWidget *vbox);
GtkWidget * GtkWidget *
about_dialog_create (GimpContext *context) about_dialog_create (GimpContext *context)
{ {
static GimpAboutDialog *dialog = NULL; static GimpAboutDialog dialog;
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
if (! dialog) if (! dialog.dialog)
{ {
GtkWidget *widget; GtkWidget *widget;
GtkWidget *container; GtkWidget *container;
@ -99,9 +99,7 @@ about_dialog_create (GimpContext *context)
GList *children; GList *children;
gchar *copyright; 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 (); pixbuf = about_dialog_load_logo ();
@ -133,9 +131,9 @@ about_dialog_create (GimpContext *context)
g_free (copyright); 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_signal_connect (widget, "response",
G_CALLBACK (gtk_widget_destroy), G_CALLBACK (gtk_widget_destroy),
@ -143,10 +141,10 @@ about_dialog_create (GimpContext *context)
g_signal_connect (widget, "map", g_signal_connect (widget, "map",
G_CALLBACK (about_dialog_map), G_CALLBACK (about_dialog_map),
dialog); &dialog);
g_signal_connect (widget, "unmap", g_signal_connect (widget, "unmap",
G_CALLBACK (about_dialog_unmap), G_CALLBACK (about_dialog_unmap),
dialog); &dialog);
/* kids, don't try this at home! */ /* kids, don't try this at home! */
container = gtk_dialog_get_content_area (GTK_DIALOG (widget)); container = gtk_dialog_get_content_area (GTK_DIALOG (widget));
@ -154,7 +152,7 @@ about_dialog_create (GimpContext *context)
if (GTK_IS_BOX (children->data)) 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); about_dialog_add_message (children->data);
} }
else else
@ -163,9 +161,9 @@ about_dialog_create (GimpContext *context)
g_list_free (children); 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 static void

View File

@ -473,6 +473,7 @@ dialog_info_update (GimpModuleDB *db,
for (i = 0; i < N_INFOS; i++) for (i = 0; i < N_INFOS; i++)
gtk_label_set_text (GTK_LABEL (dialog->label[i]), gtk_label_set_text (GTK_LABEL (dialog->label[i]),
text[i] ? text[i] : "--"); text[i] ? text[i] : "--");
g_free (location);
/* Show errors */ /* Show errors */
show_error = (module->state == GIMP_MODULE_STATE_ERROR && show_error = (module->state == GIMP_MODULE_STATE_ERROR &&

View File

@ -337,7 +337,7 @@ gimp_canvas_polygon_new_from_coords (GimpDisplayShell *shell,
} }
array = gimp_array_new ((const guint8 *) points, 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, item = g_object_new (GIMP_TYPE_CANVAS_POLYGON,
"shell", shell, "shell", shell,
@ -346,6 +346,7 @@ gimp_canvas_polygon_new_from_coords (GimpDisplayShell *shell,
NULL); NULL);
gimp_array_free (array); gimp_array_free (array);
g_free (points);
return item; return item;
} }

View File

@ -41,7 +41,7 @@ void
gimp_display_shell_expose_region (GimpDisplayShell *shell, gimp_display_shell_expose_region (GimpDisplayShell *shell,
cairo_region_t *region) cairo_region_t *region)
{ {
GdkRegion *gdk_region = gdk_region_new (); GdkRegion *gdk_region;
gint n_rectangles; gint n_rectangles;
gint i; gint i;
@ -51,6 +51,7 @@ gimp_display_shell_expose_region (GimpDisplayShell *shell,
if (! gtk_widget_get_realized (shell->canvas)) if (! gtk_widget_get_realized (shell->canvas))
return; return;
gdk_region = gdk_region_new ();
n_rectangles = cairo_region_num_rectangles (region); n_rectangles = cairo_region_num_rectangles (region);
for (i = 0; i < n_rectangles; i++) for (i = 0; i < n_rectangles; i++)

View File

@ -265,6 +265,7 @@ gimp_ui_configurer_move_docks_to_columns (GimpUIConfigurer *ui_configurer,
g_list_free (docks); g_list_free (docks);
} }
} }
g_list_free (dialogs);
} }
/** /**

View File

@ -178,6 +178,12 @@ gimp_paint_core_finalize (GObject *object)
g_free (core->undo_desc); g_free (core->undo_desc);
core->undo_desc = NULL; 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); G_OBJECT_CLASS (parent_class)->finalize (object);
} }

View File

@ -764,6 +764,7 @@ gimp_procedure_validate_args (GimpProcedure *procedure,
} }
} }
g_value_unset (&string_value);
return FALSE; return FALSE;
} }

View File

@ -695,6 +695,7 @@ vectors_stroke_new_from_points_invoker (GimpProcedure *procedure,
vectors); vectors);
gimp_vectors_stroke_add (vectors, stroke); gimp_vectors_stroke_add (vectors, stroke);
g_object_unref (stroke);
stroke_id = gimp_stroke_get_ID (stroke); stroke_id = gimp_stroke_get_ID (stroke);
@ -817,6 +818,7 @@ vectors_bezier_stroke_new_moveto_invoker (GimpProcedure *procedure,
vectors); vectors);
gimp_vectors_stroke_add (vectors, stroke); gimp_vectors_stroke_add (vectors, stroke);
g_object_unref (stroke);
stroke_id = gimp_stroke_get_ID (stroke); stroke_id = gimp_stroke_get_ID (stroke);
} }
@ -1036,6 +1038,7 @@ vectors_bezier_stroke_new_ellipse_invoker (GimpProcedure *procedure,
vectors); vectors);
gimp_vectors_stroke_add (vectors, stroke); gimp_vectors_stroke_add (vectors, stroke);
g_object_unref (stroke);
stroke_id = gimp_stroke_get_ID (stroke); stroke_id = gimp_stroke_get_ID (stroke);
} }

View File

@ -22,6 +22,7 @@
#include <gegl.h> #include <gegl.h>
#include "libgimpbase/gimpbase.h"
#include "text-types.h" #include "text-types.h"
#include "core/gimp.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. * while the text layer is saved to XCF.
*/ */
gimp_item_parasite_attach (GIMP_ITEM (layer), parasite, FALSE); gimp_item_parasite_attach (GIMP_ITEM (layer), parasite, FALSE);
gimp_parasite_free (parasite);
} }
} }

View File

@ -550,6 +550,7 @@ gimp_text_layout_set_markup (GimpTextLayout *layout)
g_free (close_tag); g_free (close_tag);
pango_layout_set_markup (layout->layout, markup, -1); pango_layout_set_markup (layout->layout, markup, -1);
g_free (markup);
} }
static void static void

View File

@ -1049,7 +1049,7 @@ gimp_draw_tool_on_vectors_handle (GimpDrawTool *draw_tool,
while ((stroke = gimp_vectors_stroke_get_next (vectors, stroke))) while ((stroke = gimp_vectors_stroke_get_next (vectors, stroke)))
{ {
GList *anchor_list = gimp_stroke_get_draw_anchors (stroke); GList *anchor_list;
GList *list; GList *list;
anchor_list = g_list_concat (gimp_stroke_get_draw_anchors (stroke), anchor_list = g_list_concat (gimp_stroke_get_draw_anchors (stroke),

View File

@ -341,6 +341,7 @@ gimp_vector_tool_button_press (GimpTool *tool,
vector_tool->cur_stroke = gimp_bezier_stroke_new (); vector_tool->cur_stroke = gimp_bezier_stroke_new ();
gimp_vectors_stroke_add (vector_tool->vectors, vector_tool->cur_stroke); gimp_vectors_stroke_add (vector_tool->vectors, vector_tool->cur_stroke);
g_object_unref (vector_tool->cur_stroke);
vector_tool->undo_motion = TRUE; vector_tool->undo_motion = TRUE;
@ -610,7 +611,6 @@ gimp_vector_tool_button_press (GimpTool *tool,
/* deleting a segment (opening up a stroke) */ /* deleting a segment (opening up a stroke) */
if (vector_tool->function == VECTORS_DELETE_SEGMENT && if (vector_tool->function == VECTORS_DELETE_SEGMENT &&
gimp_vector_tool_check_writable (vector_tool)) 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, new_stroke = gimp_stroke_open (vector_tool->cur_stroke,
vector_tool->cur_anchor); vector_tool->cur_anchor);
if (new_stroke) 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->undo_motion = TRUE;
vector_tool->cur_stroke = NULL; 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); anchors = gimp_stroke_get_draw_controls (cur_stroke);
for (list = anchors; list; list = g_list_next (list)) 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) if (cur_anchor == vector_tool->cur_anchor)
cur_anchor_valid = TRUE; cur_anchor_valid = TRUE;
} }
g_list_free (anchors);
} }
if (! cur_stroke_valid) if (! cur_stroke_valid)

View File

@ -356,7 +356,7 @@ gimp_vectors_import (GimpImage *image,
if (! merge) if (! merge)
gimp_vectors_thaw (vectors); gimp_vectors_thaw (vectors);
g_list_free (path->strokes); g_list_free_full (path->strokes, g_object_unref);
path->strokes = NULL; path->strokes = NULL;
} }

View File

@ -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, ret_bezdesc = gimp_bezier_desc_new ((cairo_path_data_t *) cmd_array->data,
cmd_array->len); cmd_array->len);
g_array_free (cmd_array, FALSE);
} }
g_array_free (cmd_array, FALSE);
return ret_bezdesc; return ret_bezdesc;
} }

View File

@ -313,6 +313,8 @@ gimp_controller_list_init (GimpControllerList *list)
gtk_widget_set_sensitive (list->edit_button, FALSE); gtk_widget_set_sensitive (list->edit_button, FALSE);
gtk_widget_set_sensitive (list->up_button, FALSE); gtk_widget_set_sensitive (list->up_button, FALSE);
gtk_widget_set_sensitive (list->down_button, FALSE); gtk_widget_set_sensitive (list->down_button, FALSE);
g_free (controller_types);
} }
static void static void

View File

@ -487,6 +487,7 @@ gimp_device_info_editor_constructed (GObject *object)
label = gtk_label_new (string); label = gtk_label_new (string);
gtk_container_add (GTK_CONTAINER (frame), label); gtk_container_add (GTK_CONTAINER (frame), label);
gtk_widget_show (label); gtk_widget_show (label);
g_free (string);
} }
} }
} }

View File

@ -875,6 +875,7 @@ gimp_tag_entry_parse_tags (GimpTagEntry *entry)
} }
parsed_tags[length] = NULL; parsed_tags[length] = NULL;
g_list_free (tag_list);
return parsed_tags; return parsed_tags;
} }

View File

@ -236,6 +236,7 @@ gimp_text_buffer_serialize (GtkTextBuffer *register_buffer,
} }
while (! gtk_text_iter_equal (&iter, end)); while (! gtk_text_iter_equal (&iter, end));
g_slist_free (tag_list);
/* Close any open tags */ /* Close any open tags */
for (tag_list = active_tags; tag_list; tag_list = tag_list->next) for (tag_list = active_tags; tag_list; tag_list = tag_list->next)
close_tag (GIMP_TEXT_BUFFER (register_buffer), string, tag_list->data); close_tag (GIMP_TEXT_BUFFER (register_buffer), string, tag_list->data);

View File

@ -424,6 +424,7 @@ gimp_text_style_editor_finalize (GObject *object)
editor->fonts = NULL; editor->fonts = NULL;
} }
g_list_free (editor->toggles);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }

View File

@ -241,6 +241,8 @@ xcf_load_image (Gimp *gimp,
NULL)); NULL));
container = gimp_viewable_get_children (GIMP_VIEWABLE (parent)); container = gimp_viewable_get_children (GIMP_VIEWABLE (parent));
g_list_free (item_path);
} }
else else
{ {
@ -1727,7 +1729,10 @@ xcf_load_old_path (XcfInfo *info,
/* skip empty compatibility paths */ /* skip empty compatibility paths */
if (num_points == 0) if (num_points == 0)
return FALSE; {
g_free (name);
return FALSE;
}
points = g_new0 (GimpVectorsCompatPoint, num_points); points = g_new0 (GimpVectorsCompatPoint, num_points);
@ -1856,6 +1861,7 @@ xcf_load_vector (XcfInfo *info,
#endif #endif
vectors = gimp_vectors_new (image, name); vectors = gimp_vectors_new (image, name);
g_free (name);
gimp_item_set_visible (GIMP_ITEM (vectors), visible, FALSE); gimp_item_set_visible (GIMP_ITEM (vectors), visible, FALSE);
gimp_item_set_linked (GIMP_ITEM (vectors), linked, FALSE); gimp_item_set_linked (GIMP_ITEM (vectors), linked, FALSE);
@ -1957,6 +1963,9 @@ xcf_load_vector (XcfInfo *info,
NULL); NULL);
gimp_vectors_stroke_add (vectors, stroke); gimp_vectors_stroke_add (vectors, stroke);
g_object_unref (stroke);
g_value_array_free (control_points);
} }
gimp_image_add_vectors (image, vectors, gimp_image_add_vectors (image, vectors,

View File

@ -333,6 +333,7 @@ gimp_number_pair_entry_finalize (GObject *object)
priv->num_separators = 0; priv->num_separators = 0;
} }
g_free (priv->default_text);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }

View File

@ -741,6 +741,7 @@ HELP
vectors); vectors);
gimp_vectors_stroke_add (vectors, stroke); gimp_vectors_stroke_add (vectors, stroke);
g_object_unref (stroke);
stroke_id = gimp_stroke_get_ID (stroke); stroke_id = gimp_stroke_get_ID (stroke);
@ -797,6 +798,7 @@ HELP
vectors); vectors);
gimp_vectors_stroke_add (vectors, stroke); gimp_vectors_stroke_add (vectors, stroke);
g_object_unref (stroke);
stroke_id = gimp_stroke_get_ID (stroke); stroke_id = gimp_stroke_get_ID (stroke);
} }
@ -1021,6 +1023,7 @@ HELP
vectors); vectors);
gimp_vectors_stroke_add (vectors, stroke); gimp_vectors_stroke_add (vectors, stroke);
g_object_unref (stroke);
stroke_id = gimp_stroke_get_ID (stroke); stroke_id = gimp_stroke_get_ID (stroke);
} }