[gthumb] Simplification of file_data_list_from_uri_list and fix some memory leaks



commit 19ccb91a90a9d5fce72323a6d160ac7deff343b8
Author: Marc Pavot <marc pavot gmail com>
Date:   Mon Jun 8 19:52:07 2009 +0200

    Simplification of file_data_list_from_uri_list and fix some memory leaks
---
 libgthumb/file-data.c              |   10 ++--------
 libgthumb/gth-monitor.c            |    6 +++++-
 src/gth-window-actions-callbacks.c |    1 +
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/libgthumb/file-data.c b/libgthumb/file-data.c
index 283a23b..9e5cde7 100644
--- a/libgthumb/file-data.c
+++ b/libgthumb/file-data.c
@@ -332,18 +332,12 @@ file_data_list_from_uri_list (GList *list)
 GList*
 file_data_list_dup (GList *list)
 {
-	GList *new_list = NULL, *scan;
-
 	if (list == NULL)
 		return NULL;
 
-	for (scan = list; scan; scan = scan->next) {
-		FileData *data = scan->data;
-		file_data_ref (data);
-		new_list = g_list_prepend (new_list, data);
-	}
+        g_list_foreach (list, (GFunc) file_data_ref, NULL);
 
-	return g_list_reverse (new_list);
+        return g_list_copy (list);
 }
 
 
diff --git a/libgthumb/gth-monitor.c b/libgthumb/gth-monitor.c
index 5f9602b..549adb7 100644
--- a/libgthumb/gth-monitor.c
+++ b/libgthumb/gth-monitor.c
@@ -126,10 +126,14 @@ find_monitor_from_uri (GList      *gfile_monitors,
 
 	for (scan = gfile_monitors; scan; scan = scan->next) {
 		MonitorHandle *mh = scan->data;
-		if (same_uri (mh->uri, utf8_uri))
+		if (same_uri (mh->uri, utf8_uri)) {
+                        g_free (utf8_uri);
 			return scan;
+                }
 	}
 
+        g_free (utf8_uri);
+
 	return NULL;
 }
 
diff --git a/src/gth-window-actions-callbacks.c b/src/gth-window-actions-callbacks.c
index 29237ce..f808daf 100644
--- a/src/gth-window-actions-callbacks.c
+++ b/src/gth-window-actions-callbacks.c
@@ -248,6 +248,7 @@ gth_window_activate_action_file_print (GtkAction *action,
 			fd = file_data_dup (current->data);
 			file_data_set_path (fd, tmp_filename);
 			comment_copy (image_filename, fd->utf8_path);
+                        file_data_unref (fd);
 		}
 
 		print_catalog_dlg_full (GTK_WINDOW (window), list, print_done_cb, get_uri_from_local_path (tmp_filename));



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