[gthumb/gthumb-2-14] fixed a good amount of memory leaks



commit 892797c479ee90e07bbf50d5151ec271c3aab357
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Mar 24 17:09:41 2012 +0100

    fixed a good amount of memory leaks

 extensions/bookmarks/callbacks.c               |    6 +++-
 extensions/cairo_io/cairo-io-png.c             |    1 +
 extensions/catalogs/gth-catalog.c              |   12 +++++++-
 extensions/catalogs/gth-file-source-catalogs.c |   13 ++++++---
 extensions/catalogs/gth-organize-task.c        |    2 +-
 extensions/comments/gth-comment.c              |    1 +
 extensions/exiv2_tools/exiv2-utils.cpp         |    7 +++-
 extensions/file_manager/callbacks.c            |    2 +-
 gthumb/gio-utils.c                             |    2 +-
 gthumb/glib-utils.c                            |   13 ++++++---
 gthumb/gnome-desktop-thumbnail.c               |    2 +-
 gthumb/gth-browser.c                           |    6 +++-
 gthumb/gth-extensions.c                        |    6 +++-
 gthumb/gth-file-data.c                         |    2 +
 gthumb/gth-file-list.c                         |    1 +
 gthumb/gth-file-store.c                        |   32 ++++++++++++++++++-----
 gthumb/gth-filter-file.c                       |    2 +
 gthumb/gth-filter.c                            |    2 +
 gthumb/gth-image-loader.c                      |   15 ++++++-----
 gthumb/gth-image-viewer.c                      |    1 +
 gthumb/gth-image.c                             |    5 ++-
 gthumb/gth-location-chooser.c                  |    2 +
 gthumb/gth-main.c                              |   13 +++++----
 gthumb/gth-tags-file.c                         |    2 +
 gthumb/gth-test-chain.c                        |    1 +
 gthumb/gth-test.c                              |    1 +
 gthumb/gth-thumb-loader.c                      |    4 +++
 gthumb/gth-time-selector.c                     |    2 +
 gthumb/gtk-utils.c                             |    2 +-
 29 files changed, 117 insertions(+), 43 deletions(-)
---
diff --git a/extensions/bookmarks/callbacks.c b/extensions/bookmarks/callbacks.c
index e55eff7..af23ae8 100644
--- a/extensions/bookmarks/callbacks.c
+++ b/extensions/bookmarks/callbacks.c
@@ -138,8 +138,10 @@ update_system_bookmark_list_from_content (GthBrowser *browser,
 
 		line = g_strsplit (lines[i], " ", 2);
 		uri = line[0];
-		if (uri == NULL)
+		if (uri == NULL) {
+			g_strfreev (line);
 			continue;
+		}
 
 		file = g_file_new_for_uri (uri);
 		icon = _g_file_get_icon (file);
@@ -159,7 +161,7 @@ update_system_bookmark_list_from_content (GthBrowser *browser,
 						      -1);
 
 		g_free (name);
-		g_object_unref (icon);
+		_g_object_unref (icon);
 		g_object_unref (file);
 		g_strfreev (line);
 	}
diff --git a/extensions/cairo_io/cairo-io-png.c b/extensions/cairo_io/cairo-io-png.c
index 45d0c9d..bc3357d 100644
--- a/extensions/cairo_io/cairo-io-png.c
+++ b/extensions/cairo_io/cairo-io-png.c
@@ -245,6 +245,7 @@ _cairo_image_surface_create_from_png (GthFileData   *file_data,
 	if (cairo_surface_status (cairo_png_data->surface) == CAIRO_STATUS_SUCCESS)
 		gth_image_set_cairo_surface (image, cairo_png_data->surface);
 
+	g_free (row_pointers);
 	_cairo_png_data_destroy (cairo_png_data);
 
 	return image;
diff --git a/extensions/catalogs/gth-catalog.c b/extensions/catalogs/gth-catalog.c
index 3eb1efd..0366ca8 100644
--- a/extensions/catalogs/gth-catalog.c
+++ b/extensions/catalogs/gth-catalog.c
@@ -672,6 +672,8 @@ get_display_name (GFile       *file,
 		}
 	}
 
+	g_free (basename);
+
 	return g_string_free (display_name, FALSE);
 }
 
@@ -705,6 +707,8 @@ get_edit_name (GFile       *file,
 			g_string_append (display_name, name);
 	}
 
+	g_free (basename);
+
 	return g_string_free (display_name, FALSE);
 }
 
@@ -725,6 +729,8 @@ update_standard_attributes (GFile       *file,
 		sort_order_s = gth_datetime_strftime (date_time, "%Y%m%d");
 		sort_order = atoi (sort_order_s);
 		g_file_info_set_sort_order (info, sort_order);
+
+		g_free (sort_order_s);
 	}
 	else if (g_file_info_get_attribute_boolean (info, "gthumb::no-child"))
 		g_file_info_set_sort_order (info, 99999999);
@@ -852,6 +858,7 @@ gth_catalog_file_to_gio_file (GFile *file)
 			full_uri = g_strconcat (base_uri, part ? "/" : NULL, part, NULL);
 			gio_file = g_file_new_for_uri (full_uri);
 
+			g_free (full_uri);
 			g_free (base_uri);
 			g_object_unref (base);
 		}
@@ -1188,7 +1195,8 @@ gth_catalog_save (GthCatalog *catalog)
 	gio_file = gth_catalog_file_to_gio_file (file);
 
 	gio_parent = g_file_get_parent (gio_file);
-	g_file_make_directory_with_parents (gio_parent, NULL, NULL);
+	if (gio_parent != NULL)
+		g_file_make_directory_with_parents (gio_parent, NULL, NULL);
 	data = gth_catalog_to_data (catalog, &size);
 	if (! g_write_file (gio_file,
 			    FALSE,
@@ -1228,6 +1236,6 @@ gth_catalog_save (GthCatalog *catalog)
 	}
 
 	g_free (data);
-	g_object_unref (gio_parent);
+	_g_object_unref (gio_parent);
 	g_object_unref (gio_file);
 }
diff --git a/extensions/catalogs/gth-file-source-catalogs.c b/extensions/catalogs/gth-file-source-catalogs.c
index 0d4b8ef..c95476d 100644
--- a/extensions/catalogs/gth-file-source-catalogs.c
+++ b/extensions/catalogs/gth-file-source-catalogs.c
@@ -71,14 +71,16 @@ update_file_info (GthFileSource *file_source,
 		  GFile         *catalog_file,
 		  GFileInfo     *info)
 {
-	char *uri;
+	char  *uri;
+	GIcon *icon = NULL;
 
 	uri = g_file_get_uri (catalog_file);
 
 	if (g_str_has_suffix (uri, ".gqv") || g_str_has_suffix (uri, ".catalog")) {
 		g_file_info_set_file_type (info, G_FILE_TYPE_DIRECTORY);
 		g_file_info_set_content_type (info, "gthumb/catalog");
-		g_file_info_set_icon (info, g_themed_icon_new ("file-catalog"));
+		icon = g_themed_icon_new ("file-catalog");
+		g_file_info_set_icon (info, icon);
 		g_file_info_set_sort_order (info, 1);
 		g_file_info_set_attribute_boolean (info, "gthumb::no-child", TRUE);
 		gth_catalog_update_standard_attributes (catalog_file, info);
@@ -86,7 +88,8 @@ update_file_info (GthFileSource *file_source,
 	else if (g_str_has_suffix (uri, ".search")) {
 		g_file_info_set_file_type (info, G_FILE_TYPE_DIRECTORY);
 		g_file_info_set_content_type (info, "gthumb/search");
-		g_file_info_set_icon (info, g_themed_icon_new ("file-search"));
+		icon = g_themed_icon_new ("file-search");
+		g_file_info_set_icon (info, icon);
 		g_file_info_set_sort_order (info, 1);
 		g_file_info_set_attribute_boolean (info, "gthumb::no-child", TRUE);
 		gth_catalog_update_standard_attributes (catalog_file, info);
@@ -94,12 +97,14 @@ update_file_info (GthFileSource *file_source,
 	else {
 		g_file_info_set_file_type (info, G_FILE_TYPE_DIRECTORY);
 		g_file_info_set_content_type (info, "gthumb/library");
-		g_file_info_set_icon (info, g_themed_icon_new ("file-library"));
+		icon = g_themed_icon_new ("file-library");
+		g_file_info_set_icon (info, icon);
 		g_file_info_set_sort_order (info, 0);
 		g_file_info_set_attribute_boolean (info, "gthumb::no-child", FALSE);
 		gth_catalog_update_standard_attributes (catalog_file, info);
 	}
 
+	_g_object_unref (icon);
 	g_free (uri);
 }
 
diff --git a/extensions/catalogs/gth-organize-task.c b/extensions/catalogs/gth-organize-task.c
index 3795628..73eb1d2 100644
--- a/extensions/catalogs/gth-organize-task.c
+++ b/extensions/catalogs/gth-organize-task.c
@@ -541,7 +541,7 @@ static void
 gth_organize_task_exec (GthTask *base)
 {
 	GthOrganizeTask *self;
-	const char      *attributes;
+	const char      *attributes = NULL;
 
 	self = GTH_ORGANIZE_TASK (base);
 
diff --git a/extensions/comments/gth-comment.c b/extensions/comments/gth-comment.c
index 60e20d1..5add997 100644
--- a/extensions/comments/gth-comment.c
+++ b/extensions/comments/gth-comment.c
@@ -346,6 +346,7 @@ gth_comment_new_for_file (GFile         *file,
 		comment = NULL;
 	}
 
+	g_object_unref (doc);
 	g_free (buffer);
 	g_free (zipped_buffer);
 
diff --git a/extensions/exiv2_tools/exiv2-utils.cpp b/extensions/exiv2_tools/exiv2-utils.cpp
index ffa66c2..c4cd641 100644
--- a/extensions/exiv2_tools/exiv2-utils.cpp
+++ b/extensions/exiv2_tools/exiv2-utils.cpp
@@ -386,7 +386,6 @@ set_attribute_from_metadata (GFileInfo  *info,
 			     const char *attribute,
 			     GObject    *metadata)
 {
-	char *key;
 	char *description;
 	char *formatted_value;
 	char *raw_value;
@@ -396,7 +395,6 @@ set_attribute_from_metadata (GFileInfo  *info,
 		return;
 
 	g_object_get (metadata,
-		      "id", &key,
 		      "description", &description,
 		      "formatted", &formatted_value,
 		      "raw", &raw_value,
@@ -410,6 +408,11 @@ set_attribute_from_metadata (GFileInfo  *info,
 		       raw_value,
 		       NULL,
 		       type_name);
+
+	g_free (description);
+	g_free (formatted_value);
+	g_free (raw_value);
+	g_free (type_name);
 }
 
 
diff --git a/extensions/file_manager/callbacks.c b/extensions/file_manager/callbacks.c
index 1b04a47..5176ee6 100644
--- a/extensions/file_manager/callbacks.c
+++ b/extensions/file_manager/callbacks.c
@@ -1106,7 +1106,7 @@ _gth_browser_update_open_menu (GthBrowser *browser,
 	gtk_widget_show (openwith_item);
 
 	g_hash_table_destroy (used_apps);
-	g_list_free (appinfo_list);
+	_g_object_list_unref (appinfo_list);
 	_g_object_list_unref (file_list);
 	_gtk_tree_path_list_free (items);
 }
diff --git a/gthumb/gio-utils.c b/gthumb/gio-utils.c
index 8cfacd7..e64c04b 100644
--- a/gthumb/gio-utils.c
+++ b/gthumb/gio-utils.c
@@ -201,7 +201,7 @@ for_each_child_data_free (ForEachChildData *fec)
 		return;
 
 	g_object_unref (fec->base_directory);
-	if (fec->already_visited)
+	if (fec->already_visited != NULL)
 		g_hash_table_destroy (fec->already_visited);
 	clear_child_data (&(fec->current));
 	if (fec->to_visit != NULL) {
diff --git a/gthumb/glib-utils.c b/gthumb/glib-utils.c
index aa3b1b7..ccf4b7d 100644
--- a/gthumb/glib-utils.c
+++ b/gthumb/glib-utils.c
@@ -1911,8 +1911,10 @@ _g_file_get_display_name (GFile *file)
 				       G_FILE_QUERY_INFO_NONE,
 				       NULL,
 				       NULL);
-	if (file_info != NULL)
+	if (file_info != NULL) {
 		name = g_strdup (g_file_info_get_attribute_string (file_info, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME));
+		g_object_unref (file_info);
+	}
 	else
 		name = g_file_get_parse_name (file);
 
@@ -2061,9 +2063,12 @@ _g_file_get_icon (GFile *file)
 				       G_FILE_QUERY_INFO_NONE,
 				       NULL,
 				       NULL);
-	if (file_info != NULL)
-		icon = (GIcon*) g_file_info_get_attribute_object (file_info, G_FILE_ATTRIBUTE_STANDARD_ICON);
-	else
+	if (file_info != NULL) {
+		icon = (GIcon*) g_object_ref (g_file_info_get_attribute_object (file_info, G_FILE_ATTRIBUTE_STANDARD_ICON));
+		g_object_unref (file_info);
+	}
+
+	if (icon == NULL)
 		icon = g_themed_icon_new ("file");
 
 	return icon;
diff --git a/gthumb/gnome-desktop-thumbnail.c b/gthumb/gnome-desktop-thumbnail.c
index d5cdec6..1f7380e 100644
--- a/gthumb/gnome-desktop-thumbnail.c
+++ b/gthumb/gnome-desktop-thumbnail.c
@@ -1788,7 +1788,7 @@ read_png_options (const char *thumbnail_filename)
 
 	f = fopen (thumbnail_filename, "r");
 	if (f == NULL) {
-		png_destroy_read_struct (&png_ptr, NULL, NULL);
+		png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
 		return options;
 	}
 
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index caf9ad1..cd918b7 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -3383,6 +3383,7 @@ pref_general_filter_changed (GConfClient *client,
 	filter = _gth_browser_get_file_filter (browser);
 	gth_file_list_set_filter (GTH_FILE_LIST (browser->priv->file_list), filter);
 	gth_file_list_set_filter (GTH_FILE_LIST (browser->priv->thumbnail_list), filter);
+
 	g_object_unref (filter);
 }
 
@@ -4083,6 +4084,7 @@ _gth_browser_construct (GthBrowser *browser)
 	GtkWidget      *menubar;
 	GtkOrientation  viewer_thumbnails_orientation;
 	char           *general_filter;
+	char           *sort_type;
 	char           *caption;
 	int             i;
 
@@ -4403,8 +4405,9 @@ _gth_browser_construct (GthBrowser *browser)
 	/* the file list */
 
 	browser->priv->file_list = gth_file_list_new (gth_icon_view_new (), GTH_FILE_LIST_TYPE_NORMAL, TRUE);
+	sort_type = eel_gconf_get_string (PREF_SORT_TYPE, "file::mtime");
 	gth_browser_set_sort_order (browser,
-				    gth_main_get_sort_type (eel_gconf_get_string (PREF_SORT_TYPE, "file::mtime")),
+				    gth_main_get_sort_type (sort_type),
 				    eel_gconf_get_boolean (PREF_SORT_INVERSE, FALSE));
 	gth_browser_enable_thumbnails (browser, eel_gconf_get_boolean (PREF_SHOW_THUMBNAILS, TRUE));
 	gth_file_list_set_thumb_size (GTH_FILE_LIST (browser->priv->file_list), eel_gconf_get_integer (PREF_THUMBNAIL_SIZE, DEF_THUMBNAIL_SIZE));
@@ -4412,6 +4415,7 @@ _gth_browser_construct (GthBrowser *browser)
 	gth_file_list_set_caption (GTH_FILE_LIST (browser->priv->file_list), caption);
 
 	g_free (caption);
+	g_free (sort_type);
 
 	gtk_widget_show (browser->priv->file_list);
 	gtk_box_pack_start (GTK_BOX (vbox), browser->priv->file_list, TRUE, TRUE, 0);
diff --git a/gthumb/gth-extensions.c b/gthumb/gth-extensions.c
index 03a11de..2c68fde 100644
--- a/gthumb/gth-extensions.c
+++ b/gthumb/gth-extensions.c
@@ -526,8 +526,11 @@ gth_extension_description_load_from_file (GthExtensionDescription *desc,
 
 	key_file = g_key_file_new ();
 	file_path = g_file_get_path (file);
-	if (! g_key_file_load_from_file (key_file, file_path, G_KEY_FILE_NONE, NULL))
+	if (! g_key_file_load_from_file (key_file, file_path, G_KEY_FILE_NONE, NULL)) {
+		g_free (file_path);
+		g_key_file_free (key_file);
 		return FALSE;
+	}
 
 	basename = g_file_get_basename (file);
 	desc->id = _g_uri_remove_extension (basename);
@@ -933,6 +936,7 @@ gth_extension_manager_order_extensions (GthExtensionManager *manager,
 				ordered = slink;
 			}
 		}
+		g_list_free (dependencies);
 
 		extensions = g_slist_remove_link (extensions, scan);
 		scan->next = ordered;
diff --git a/gthumb/gth-file-data.c b/gthumb/gth-file-data.c
index d48bc69..cebb057 100644
--- a/gthumb/gth-file-data.c
+++ b/gthumb/gth-file-data.c
@@ -565,6 +565,8 @@ gth_file_data_list_get_common_info (GList      *file_data_list,
 
 		if (first_value == NULL)
 			g_file_info_remove_attribute (info, attribute);
+
+		g_free (first_value);
 	}
 
 	g_strfreev (attributes_v);
diff --git a/gthumb/gth-file-list.c b/gthumb/gth-file-list.c
index 0d1a34f..fa6d739 100644
--- a/gthumb/gth-file-list.c
+++ b/gthumb/gth-file-list.c
@@ -1593,6 +1593,7 @@ thumbnail_job_ready_cb (GObject      *source_object,
 	if ((! success && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
 	    || file_list->priv->cancelling)
 	{
+		_g_object_unref (pixbuf);
 		thumbnail_job_free (job);
 		return;
 	}
diff --git a/gthumb/gth-file-store.c b/gthumb/gth-file-store.c
index b94e464..5945675 100644
--- a/gthumb/gth-file-store.c
+++ b/gthumb/gth-file-store.c
@@ -50,6 +50,7 @@ typedef struct {
 
 	/*< private >*/
 
+	guint        ref_count;
 	guint        pos;
 	guint        abs_pos;
 	gboolean     visible;
@@ -81,7 +82,12 @@ static GObjectClass *parent_class = NULL;
 static GthFileRow *
 _gth_file_row_new (void)
 {
-	return g_new0 (GthFileRow, 1);
+	GthFileRow *row;
+
+	row = g_new0 (GthFileRow, 1);
+	row->ref_count = 1;
+
+	return row;
 }
 
 
@@ -146,9 +152,20 @@ _gth_file_row_copy (GthFileRow *row)
 }
 
 
+static GthFileRow *
+_gth_file_row_ref (GthFileRow *row)
+{
+	row->ref_count++;
+	return row;
+}
+
+
 static void
-_gth_file_row_free (GthFileRow *row)
+_gth_file_row_unref (GthFileRow *row)
 {
+	if (--row->ref_count > 0)
+		return;
+
 	if (row->file_data != NULL)
 		g_object_unref (row->file_data);
 	if (row->thumbnail != NULL)
@@ -161,6 +178,7 @@ _gth_file_row_free (GthFileRow *row)
 static void
 _gth_file_store_clear_queue (GthFileStore *file_store)
 {
+	g_list_foreach (file_store->priv->queue, (GFunc) _gth_file_row_unref, NULL);
 	g_list_free (file_store->priv->queue);
 	file_store->priv->queue = NULL;
 }
@@ -172,7 +190,7 @@ _gth_file_store_free_rows (GthFileStore *file_store)
 	int i;
 
 	for (i = 0; i < file_store->priv->tot_rows; i++)
-		_gth_file_row_free (file_store->priv->all_rows[i]);
+		_gth_file_row_unref (file_store->priv->all_rows[i]);
 	g_free (file_store->priv->all_rows);
 	file_store->priv->all_rows = NULL;
 	file_store->priv->tot_rows = 0;
@@ -837,7 +855,7 @@ g_print ("UPDATE VISIBILITY\n");
 	for (i = 0; i < position; i++)
 		all_rows[j++] = _gth_file_row_copy (file_store->priv->all_rows[i]);
 	for (scan = add_queue; scan; scan = scan->next)
-		all_rows[j++] = (GthFileRow *) scan->data;
+		all_rows[j++] = _gth_file_row_ref ((GthFileRow *) scan->data);
 	for (i = position; i < file_store->priv->tot_rows; i++)
 		all_rows[j++] = _gth_file_row_copy (file_store->priv->all_rows[i]);
 
@@ -1007,7 +1025,7 @@ g_print ("\n");
 	_gth_file_store_increment_stamp (file_store);
 
 	for (i = 0; i < file_store->priv->tot_rows; i++)
-		_gth_file_row_free (file_store->priv->all_rows[i]);
+		_gth_file_row_unref (file_store->priv->all_rows[i]);
 	g_free (file_store->priv->all_rows);
 	file_store->priv->all_rows = all_rows;
 	file_store->priv->tot_rows = all_rows_n;
@@ -1580,7 +1598,7 @@ gth_file_store_queue_remove (GthFileStore *file_store,
 
   	row = (GthFileRow*) iter->user_data;
 
-	file_store->priv->queue = g_list_prepend (file_store->priv->queue, file_store->priv->all_rows[row->abs_pos]);
+	file_store->priv->queue = g_list_prepend (file_store->priv->queue, _gth_file_row_ref (file_store->priv->all_rows[row->abs_pos]));
 }
 
 
@@ -1600,7 +1618,7 @@ gth_file_store_exec_remove (GthFileStore *file_store)
 			_gth_file_store_hide_row (file_store, row);
 
 		file_store->priv->all_rows[row->abs_pos] = NULL;
-		_gth_file_row_free (row);
+		_gth_file_row_unref (row);
 	}
 	_gth_file_store_compact_rows (file_store);
 	_gth_file_store_clear_queue (file_store);
diff --git a/gthumb/gth-filter-file.c b/gthumb/gth-filter-file.c
index d5e006b..2f74639 100644
--- a/gthumb/gth-filter-file.c
+++ b/gthumb/gth-filter-file.c
@@ -53,6 +53,8 @@ gth_filter_file_new (void)
 void
 gth_filter_file_free (GthFilterFile *filters)
 {
+	if (filters == NULL)
+		return;
 	_g_object_list_unref (filters->items);
 	g_free (filters);
 }
diff --git a/gthumb/gth-filter.c b/gthumb/gth-filter.c
index 072bb0e..e96ad6e 100644
--- a/gthumb/gth-filter.c
+++ b/gthumb/gth-filter.c
@@ -127,6 +127,8 @@ gth_filter_real_load_from_element (DomDomizable *base,
 			test = gth_test_chain_new (GTH_MATCH_TYPE_NONE, NULL);
 			dom_domizable_load_from_element (DOM_DOMIZABLE (test), node);
 			gth_filter_set_test (self, GTH_TEST_CHAIN (test));
+
+			g_object_unref (test);
 		}
 		else if (g_strcmp0 (node->tag_name, "limit") == 0) {
 			gth_filter_set_limit (self,
diff --git a/gthumb/gth-image-loader.c b/gthumb/gth-image-loader.c
index 4edf983..f36533c 100644
--- a/gthumb/gth-image-loader.c
+++ b/gthumb/gth-image-loader.c
@@ -233,17 +233,18 @@ load_pixbuf_thread (GSimpleAsyncResult *result,
 			error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, _("No suitable loader available for this file type"));
 	}
 
-	load_result = g_new0 (LoadResult, 1);
-	load_result->image = image;
-	load_result->original_width = original_width;
-	load_result->original_height = original_height;
-
 	if (error != NULL) {
+		_g_object_unref (image);
 		g_simple_async_result_set_from_error (result, error);
 		g_error_free (error);
+		return;
 	}
-	else
-		g_simple_async_result_set_op_res_gpointer (result, load_result, (GDestroyNotify) load_result_unref);
+
+	load_result = g_new0 (LoadResult, 1);
+	load_result->image = image;
+	load_result->original_width = original_width;
+	load_result->original_height = original_height;
+	g_simple_async_result_set_op_res_gpointer (result, load_result, (GDestroyNotify) load_result_unref);
 }
 
 
diff --git a/gthumb/gth-image-viewer.c b/gthumb/gth-image-viewer.c
index 0f9ed46..117bda5 100644
--- a/gthumb/gth-image-viewer.c
+++ b/gthumb/gth-image-viewer.c
@@ -165,6 +165,7 @@ gth_image_viewer_finalize (GObject *object)
 	}
 
 	g_list_foreach (self->priv->painters, (GFunc) painter_data_free, NULL);
+	_g_object_unref (self->priv->tool);
 
 	_g_clear_object (&self->priv->animation);
 	_g_clear_object (&self->priv->iter);
diff --git a/gthumb/gth-image.c b/gthumb/gth-image.c
index cfe4467..b12c55a 100644
--- a/gthumb/gth-image.c
+++ b/gthumb/gth-image.c
@@ -220,7 +220,7 @@ gth_image_get_pixbuf (GthImage *image)
 		break;
 
 	case GTH_IMAGE_FORMAT_GDK_PIXBUF:
-		result = g_object_ref (image->priv->data.pixbuf);
+		result = _g_object_ref (image->priv->data.pixbuf);
 		break;
 
 	case GTH_IMAGE_FORMAT_GDK_PIXBUF_ANIMATION:
@@ -272,7 +272,8 @@ gth_image_get_pixbuf_animation (GthImage *image)
 		break;
 
 	case GTH_IMAGE_FORMAT_GDK_PIXBUF:
-		result = gdk_pixbuf_non_anim_new (image->priv->data.pixbuf);
+		if (image->priv->data.pixbuf != NULL)
+			result = gdk_pixbuf_non_anim_new (image->priv->data.pixbuf);
 		break;
 
 	case GTH_IMAGE_FORMAT_GDK_PIXBUF_ANIMATION:
diff --git a/gthumb/gth-location-chooser.c b/gthumb/gth-location-chooser.c
index bd5ec4e..01344f4 100644
--- a/gthumb/gth-location-chooser.c
+++ b/gthumb/gth-location-chooser.c
@@ -540,6 +540,8 @@ gth_location_chooser_set_current (GthLocationChooser *chooser,
 
 			g_object_unref (info);
 		}
+
+		_g_object_list_unref (list);
 	}
 
 	g_signal_emit (G_OBJECT (chooser), gth_location_chooser_signals[CHANGED], 0);
diff --git a/gthumb/gth-main.c b/gthumb/gth-main.c
index 4723d30..0ab35cd 100644
--- a/gthumb/gth-main.c
+++ b/gthumb/gth-main.c
@@ -146,10 +146,11 @@ gth_main_finalize (GObject *object)
 
 		if (gth_main->priv->bookmarks != NULL)
 			g_bookmark_file_free (gth_main->priv->bookmarks);
-		if (gth_main->priv->monitor != NULL)
-			g_object_unref (gth_main->priv->monitor);
-		if (gth_main->priv->extension_manager != NULL)
-			g_object_unref (gth_main->priv->extension_manager);
+
+		_g_object_unref (gth_main->priv->monitor);
+		_g_object_unref (gth_main->priv->extension_manager);
+		gth_filter_file_free (gth_main->priv->filters);
+		gth_tags_file_free (gth_main->priv->tags);
 
 		g_free (gth_main->priv);
 		gth_main->priv = NULL;
@@ -815,7 +816,6 @@ gth_main_add_general_filter (GthTest *original_filter)
 
 		new_chain = gth_test_chain_new (GTH_MATCH_TYPE_ALL, NULL);
 		gth_test_chain_add_test (GTH_TEST_CHAIN (new_chain), test);
-		g_object_unref (test);
 
 		if (strncmp (gth_test_get_id (test), "file::type::", 12) != 0) {
 			GthTest *file_type_filter;
@@ -827,6 +827,7 @@ gth_main_add_general_filter (GthTest *original_filter)
 		gth_filter_set_test (filter, GTH_TEST_CHAIN (new_chain));
 		g_object_unref (new_chain);
 
+		g_object_unref (test);
 		test = (GthTest*) filter;
 	}
 	else {
@@ -1361,7 +1362,7 @@ attribute_list_reload_required (const char *old_attributes,
 				}
 			}
 
-		g_object_ref (provider);
+		g_object_unref (provider);
 	}
 
 	/*
diff --git a/gthumb/gth-tags-file.c b/gthumb/gth-tags-file.c
index b45601a..7e8c44e 100644
--- a/gthumb/gth-tags-file.c
+++ b/gthumb/gth-tags-file.c
@@ -53,6 +53,8 @@ gth_tags_file_new (void)
 void
 gth_tags_file_free (GthTagsFile *tags)
 {
+	if (tags == NULL)
+		return;
 	_g_string_list_free (tags->items);
 	g_strfreev (tags->tags);
 	g_free (tags);
diff --git a/gthumb/gth-test-chain.c b/gthumb/gth-test-chain.c
index c5b675a..d7b6007 100644
--- a/gthumb/gth-test-chain.c
+++ b/gthumb/gth-test-chain.c
@@ -52,6 +52,7 @@ gth_test_chain_finalize (GObject *object)
 		_g_object_list_unref (test->priv->tests);
 		if (test->priv->attributes != NULL)
 			g_string_free (test->priv->attributes, TRUE);
+		g_free (test->priv);
 		test->priv = NULL;
 	}
 
diff --git a/gthumb/gth-test.c b/gthumb/gth-test.c
index dd0aa23..0865781 100644
--- a/gthumb/gth-test.c
+++ b/gthumb/gth-test.c
@@ -72,6 +72,7 @@ gth_test_finalize (GObject *object)
 	self = GTH_TEST (object);
 
 	g_free (self->priv->id);
+	g_free (self->priv->attributes);
 	g_free (self->priv->display_name);
 	g_free (self->files);
 
diff --git a/gthumb/gth-thumb-loader.c b/gthumb/gth-thumb-loader.c
index 19e6ea7..e39d6b7 100644
--- a/gthumb/gth-thumb-loader.c
+++ b/gthumb/gth-thumb-loader.c
@@ -361,7 +361,9 @@ load_data_unref (LoadData *load_data)
 {
 	g_object_unref (load_data->thumb_loader);
 	g_object_unref (load_data->file_data);
+	_g_object_unref (load_data->simple);
 	_g_object_unref (load_data->cancellable);
+	g_free (load_data->thumbnailer_tmpfile);
 	g_free (load_data);
 }
 
@@ -835,6 +837,7 @@ gth_thumb_loader_load (GthThumbLoader      *self,
 
 			g_error_free (error);
 			g_free (uri);
+			g_object_unref (simple);
 
 			return;
 		}
@@ -855,6 +858,7 @@ gth_thumb_loader_load (GthThumbLoader      *self,
 		g_simple_async_result_complete_in_idle (simple);
 
 		g_error_free (error);
+		g_object_unref (simple);
 
 		return;
 	}
diff --git a/gthumb/gth-time-selector.c b/gthumb/gth-time-selector.c
index b41e55d..2ea8240 100644
--- a/gthumb/gth-time-selector.c
+++ b/gthumb/gth-time-selector.c
@@ -209,6 +209,8 @@ update_view_from_data (GthTimeSelector *self)
 			text = gth_datetime_strftime (self->priv->date_time, "%X");
 			entry = gtk_bin_get_child (GTK_BIN (self->priv->time_combo_box));
 			gtk_entry_set_text (GTK_ENTRY (entry), text);
+
+			g_free (text);
 		}
 		else {
 			GtkWidget *entry;
diff --git a/gthumb/gtk-utils.c b/gthumb/gtk-utils.c
index 58047f2..5e7aca8 100644
--- a/gthumb/gtk-utils.c
+++ b/gthumb/gtk-utils.c
@@ -635,7 +635,7 @@ _g_icon_get_pixbuf (GIcon        *icon,
 	pixbuf = NULL;
 	if (G_IS_THEMED_ICON (icon))
 		pixbuf = get_themed_icon_pixbuf (G_THEMED_ICON (icon), size, theme);
-	if (G_IS_FILE_ICON (icon))
+	else if (G_IS_FILE_ICON (icon))
 		pixbuf = get_file_icon_pixbuf (G_FILE_ICON (icon), size);
 
 	if (pixbuf == NULL)



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