[gthumb] Improve GIO Error handling



commit 7b570967259f023e635fa1c52b0d98c20f314cb5
Author: Marlodavampire <brooss teambb gmail com>
Date:   Thu Jun 25 08:15:46 2009 -0400

    Improve GIO Error handling
    
    Remeber to call g_error_free on errors in a few places
    Fix a mistake with error handling in path_list_next_files_cb
    Only request standard file attributes in path_list_async_new
    Pass the right gfile to gfile_warning in directory_load_cb
    Improve error handling for symlinks in dlg-search

 libgthumb/file-utils.c |    7 ++++---
 src/dlg-duplicates.c   |    7 +++++--
 src/dlg-search.c       |   25 +++++++++++++------------
 3 files changed, 22 insertions(+), 17 deletions(-)
---
diff --git a/libgthumb/file-utils.c b/libgthumb/file-utils.c
index c6e8314..7112a27 100644
--- a/libgthumb/file-utils.c
+++ b/libgthumb/file-utils.c
@@ -191,11 +191,11 @@ path_list_next_files_cb (GObject      *source_object,
 		   GAsyncResult *res,
 		   gpointer      data)
 {
-	GError    *error=NULL;
 	PathListData *pli = (PathListData *) data;
 	
-	pli->file_list = g_file_enumerator_next_files_finish (pli->gfile_enum, res ,&error);
+	pli->file_list = g_file_enumerator_next_files_finish (pli->gfile_enum, res ,&pli->error);
 	if (pli->error != NULL) {
+		g_error_free (pli->error);
 		if (pli->done_func) {
 			/* pli is deallocated in pli->done_func */
 			pli->done_func (pli, pli->done_data);
@@ -215,6 +215,7 @@ directory_load_cb (GObject      *source_object,
 	pli = (PathListData *) data;
 	pli->gfile_enum = g_file_enumerate_children_finish (pli->gfile, res, &pli->error);
 	if (pli->error != NULL) {
+		g_error_free (pli->error);
 		if (pli->done_func) {
 			/* pli is deallocated in pli->done_func */
 			pli->done_func (pli, pli->done_data);
@@ -269,7 +270,7 @@ path_list_async_new (const char         *uri,
 	pli->fast_file_type = fast_file_type;
 	pli->cancelled = g_cancellable_new();
 	g_file_enumerate_children_async (pli->gfile,
-                                         "*",
+                                         "standard::*",
                                          G_FILE_QUERY_INFO_NONE,
                                          G_PRIORITY_DEFAULT,
                                          pli->cancelled,
diff --git a/src/dlg-duplicates.c b/src/dlg-duplicates.c
index 56db335..e3e19d6 100644
--- a/src/dlg-duplicates.c
+++ b/src/dlg-duplicates.c
@@ -1315,6 +1315,7 @@ read_callback (GObject      *source_object,
 		g_input_stream_close_async (G_INPUT_STREAM(data->stream), G_PRIORITY_DEFAULT, NULL, close_callback, data);
 		data->scanning_dir = FALSE;
 		data->checking_file = FALSE;
+		g_error_free (error);
 		search_finished (data);
 		return;
 	}
@@ -1383,11 +1384,12 @@ open_callback (GObject      *source_object,
 	DialogData *data = callback_data;
 	GError *error = NULL;
 	data->stream = g_file_read_finish (data->current_gfile, res, &error);
-	if (data->stream == NULL) { 
+	if (data->stream == NULL) {
 		gfile_warning ("Cannot load file", data->current_gfile, error);
 
 		/* No need to stop the search for an error opening a file.
 		 * Some MTP devices seem to have files that can't be read */
+		g_error_free (error);
 		start_next_checksum (data);
 		return;
 	}
@@ -1522,10 +1524,11 @@ directory_load_cb (GObject       *source_object,
 	data->gfile_enum = g_file_enumerate_children_finish (data->gfile, res, &error);
 
 	if(data->gfile_enum == NULL) {
-		gfile_warning ("Cannot load directory", data->current_gfile, error);
+		gfile_warning ("Cannot load directory", data->gfile, error);
 
 		/* Lots off errors here will likley only be permission related,
 		 * no need to stop our search, ignore this dir and keep going */
+		g_error_free (error);
 		scan_next_dir (data);
 		return;
 	}
diff --git a/src/dlg-search.c b/src/dlg-search.c
index 403127c..d0df6ba 100644
--- a/src/dlg-search.c
+++ b/src/dlg-search.c
@@ -1048,20 +1048,21 @@ search_dir_next_files_cb (GObject      *source_object,
 			GFile     *sym_target = NULL;
 			GFileInfo *info2;
 			GError    *error = NULL;
-
 			child = g_file_get_child (data->gfile, g_file_info_get_name (info));
-			sym_target = g_file_resolve_relative_path (child, g_file_info_get_symlink_target (info));
-			path = g_file_get_parent (sym_target);
-			info2 = g_file_query_info (sym_target, "standard::*", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, &error);
-			g_object_unref (info);
-			info = info2;
-
-			if (info == NULL) {
-				gfile_warning ("Cannot resolve symlink", sym_target, error);
-				g_error_free(error);
+			if (g_file_info_get_symlink_target (info) != NULL) {
+				sym_target = g_file_resolve_relative_path (child, g_file_info_get_symlink_target (info));
+				path = g_file_get_parent (sym_target);
+				if (path == NULL)
+					path = gfile_new ("file:///");
+				info2 = g_file_query_info (sym_target, "standard::*", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, &error);
+				g_object_unref (info);
+				info = info2;
+				if (info == NULL) {
+					gfile_warning ("Cannot resolve symlink", sym_target, error);
+					g_error_free(error);
+				}
+				g_object_unref (sym_target);
 			}
-
-			g_object_unref (sym_target);
 			g_object_unref (child);
 		}
 		if (info != NULL) {



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