From 2b56a5ea0fd856e3a70684fa83e9dc8f938145e2 Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Thu, 12 Aug 2010 11:23:55 +0100 Subject: [PATCH] background: fix various leaks Fix various leaks found by valgrind. --- panels/background/bg-colors-source.c | 2 ++ panels/background/bg-flickr-source.c | 1 + panels/background/bg-pictures-source.c | 1 + panels/background/cc-background-panel.c | 2 +- panels/background/gnome-wp-info.c | 2 ++ panels/background/gnome-wp-item.c | 9 ++++++--- panels/background/gnome-wp-xml.c | 1 + 7 files changed, 14 insertions(+), 4 deletions(-) diff --git a/panels/background/bg-colors-source.c b/panels/background/bg-colors-source.c index fd3ae667b..4c07da19b 100644 --- a/panels/background/bg-colors-source.c +++ b/panels/background/bg-colors-source.c @@ -105,6 +105,8 @@ bg_colors_source_init (BgColorsSource *self) 0, pixbuf, 1, item, -1); + + g_object_unref (pixbuf); } g_object_unref (thumb_factory); diff --git a/panels/background/bg-flickr-source.c b/panels/background/bg-flickr-source.c index 71aad57ed..50aeb03da 100644 --- a/panels/background/bg-flickr-source.c +++ b/panels/background/bg-flickr-source.c @@ -116,6 +116,7 @@ _view_items_added_cb (SwClientItemView *item_view, 0, pixbuf, 1, item, -1); + g_object_unref (pixbuf); } } diff --git a/panels/background/bg-pictures-source.c b/panels/background/bg-pictures-source.c index 9e05855fe..59632eafe 100644 --- a/panels/background/bg-pictures-source.c +++ b/panels/background/bg-pictures-source.c @@ -198,6 +198,7 @@ file_info_async_ready (GObject *source, gtk_tree_path_free (tree_path); g_free (filename); + g_object_unref (pixbuf); } } diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c index f550f0845..0bac1ecb3 100644 --- a/panels/background/cc-background-panel.c +++ b/panels/background/cc-background-panel.c @@ -326,6 +326,7 @@ backgrounds_changed_cb (GtkIconView *icon_view, gtk_tree_model_get_iter (model, &iter, (GtkTreePath*) list->data); + g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL); g_list_free (list); gtk_tree_model_get (model, &iter, 1, &item, -1); @@ -457,7 +458,6 @@ preview_expose_cb (GtkWidget *widget, priv->thumb_factory, allocation.width, allocation.height); - g_object_ref (pixbuf); } if (pixbuf) diff --git a/panels/background/gnome-wp-info.c b/panels/background/gnome-wp-info.c index 7df6030ae..4cdb25811 100644 --- a/panels/background/gnome-wp-info.c +++ b/panels/background/gnome-wp-info.c @@ -84,4 +84,6 @@ void gnome_wp_info_free (GnomeWPInfo * info) { g_free (info->thumburi); g_free (info->name); g_free (info->mime_type); + + g_free (info); } diff --git a/panels/background/gnome-wp-item.c b/panels/background/gnome-wp-item.c index 09685e1c9..703b8531e 100644 --- a/panels/background/gnome-wp-item.c +++ b/panels/background/gnome-wp-item.c @@ -183,6 +183,8 @@ void gnome_wp_item_free (GnomeWPItem * item) { gtk_tree_row_reference_free (item->rowref); + g_free (item->source_url); + g_free (item); } @@ -256,7 +258,7 @@ void gnome_wp_item_update_description (GnomeWPItem * item) { if (!strcmp (item->filename, "(none)")) { item->description = g_strdup (item->name); } else { - const gchar *description; + gchar *description; gchar *size; gchar *dirname = g_path_get_dirname (item->filename); @@ -266,9 +268,9 @@ void gnome_wp_item_update_description (GnomeWPItem * item) { if (strcmp (item->fileinfo->mime_type, "application/xml") == 0) { if (gnome_bg_changes_with_time (item->bg)) - description = _("Slide Show"); + description = g_strdup (_("Slide Show")); else if (item->width > 0 && item->height > 0) - description = _("Image"); + description = g_strdup (_("Image")); } else description = g_content_type_get_description (item->fileinfo->mime_type); @@ -311,5 +313,6 @@ void gnome_wp_item_update_description (GnomeWPItem * item) { g_free (size); g_free (dirname); + g_free (description); } } diff --git a/panels/background/gnome-wp-xml.c b/panels/background/gnome-wp-xml.c index 51aba445f..1abe2e171 100644 --- a/panels/background/gnome-wp-xml.c +++ b/panels/background/gnome-wp-xml.c @@ -333,6 +333,7 @@ static void gnome_wp_xml_load_from_dir (const gchar *path, gnome_wp_xml_add_monitor (directory, data); g_object_unref (directory); + g_object_unref (enumerator); } void gnome_wp_xml_load_list (GnomeWpXml *data) {