[Xfce4-commits] r29874 - in thunar/branches/migration-to-gio: . thunar

Jannis Pohlmann jannis at xfce.org
Tue Apr 21 12:08:08 CEST 2009


Author: jannis
Date: 2009-04-21 10:08:08 +0000 (Tue, 21 Apr 2009)
New Revision: 29874

Modified:
   thunar/branches/migration-to-gio/ChangeLog
   thunar/branches/migration-to-gio/thunar/thunar-deep-count-job.c
   thunar/branches/migration-to-gio/thunar/thunar-gio-extensions.c
   thunar/branches/migration-to-gio/thunar/thunar-gio-extensions.h
Log:
	* thunar/thunar-deep-count-job.c: Improve the error handling code in
	  thunar_deep_count_job_execute().
	* thunar/thunar-gio-extensions.{c,h}: Add G_TYPE_FILE_LIST macro and
	  g_file_list_get_type() for a boxed GFile list type. Fix
	  g_file_list_copy() to actually return the list copy and not the
	  original. Don't set the original to NULL before iterating over it.

Modified: thunar/branches/migration-to-gio/ChangeLog
===================================================================
--- thunar/branches/migration-to-gio/ChangeLog	2009-04-20 21:22:31 UTC (rev 29873)
+++ thunar/branches/migration-to-gio/ChangeLog	2009-04-21 10:08:08 UTC (rev 29874)
@@ -1,3 +1,12 @@
+2009-04-21	Jannis Pohlmann <jannis at xfce.org>
+
+	* thunar/thunar-deep-count-job.c: Improve the error handling code in
+	  thunar_deep_count_job_execute(). 
+	* thunar/thunar-gio-extensions.{c,h}: Add G_TYPE_FILE_LIST macro and
+	  g_file_list_get_type() for a boxed GFile list type. Fix
+	  g_file_list_copy() to actually return the list copy and not the
+	  original. Don't set the original to NULL before iterating over it.
+
 2009-04-20	Jannis Pohlmann <jannis at xfce.org>
 
 	* thunar/thunar-window.c: Fix runtime error due to an NULL path being

Modified: thunar/branches/migration-to-gio/thunar/thunar-deep-count-job.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-deep-count-job.c	2009-04-20 21:22:31 UTC (rev 29873)
+++ thunar/branches/migration-to-gio/thunar/thunar-deep-count-job.c	2009-04-21 10:08:08 UTC (rev 29874)
@@ -274,8 +274,7 @@
                     break;
 
                   /* generate a GFile for the child */
-                  child = g_file_resolve_relative_path (file, 
-                                                        g_file_info_get_name (child_info));
+                  child = g_file_resolve_relative_path (file, g_file_info_get_name (child_info));
 
                   /* recurse unless the job was cancelled before */
                   if (!thunar_job_is_cancelled (job))
@@ -319,6 +318,7 @@
                                GError   **error)
 {
   gboolean success;
+  GError  *err = NULL;
 
   _thunar_return_val_if_fail (THUNAR_IS_JOB (job), FALSE);
   _thunar_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -330,21 +330,29 @@
   /* count files, directories and compute size of the job file */
   success = thunar_deep_count_job_process (job, 
                                            THUNAR_DEEP_COUNT_JOB (job)->file, 
-                                           error);
+                                           &err);
 
-  /* avoid overwriting the error if the job was cancelled */
-  if (*error != NULL && thunar_job_is_cancelled (job))
+  if (!success)
     {
-      g_error_free (*error);
-      *error = NULL;
+      g_assert (err != NULL || thunar_job_is_cancelled (job));
+
+      /* set error if the job was cancelled. otherwise just propagate 
+       * the results of the processing function */
+      if (thunar_job_set_error_if_cancelled (job, error))
+        {
+          if (err != NULL)
+            g_error_free (err);
+        }
+      else
+        {
+          if (err != NULL)
+            g_propagate_error (error, err);
+        }
+      
+      return FALSE;
     }
-
-  /* set error if the job was cancelled. otherwise just propagate 
-   * the results of the processing function */
-  if (thunar_job_set_error_if_cancelled (job, error))
-    return FALSE;
   else
-    return success;
+    return TRUE;
 }
 
 

Modified: thunar/branches/migration-to-gio/thunar/thunar-gio-extensions.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-gio-extensions.c	2009-04-20 21:22:31 UTC (rev 29873)
+++ thunar/branches/migration-to-gio/thunar/thunar-gio-extensions.c	2009-04-21 10:08:08 UTC (rev 29874)
@@ -198,10 +198,10 @@
   GList *copy = NULL;
   GList *lp;
 
-  for (list = NULL, lp = g_list_last (list); lp != NULL; lp = lp->prev)
+  for (lp = g_list_last (list); lp != NULL; lp = lp->prev)
     copy = g_list_prepend (copy, g_object_ref (lp->data));
 
-  return list;
+  return copy;
 }
 
 
@@ -240,3 +240,20 @@
 
   return buffer;
 }
+
+
+
+GType
+g_file_list_get_type (void)
+{
+  static GType type = G_TYPE_INVALID;
+
+  if (G_UNLIKELY (type == G_TYPE_INVALID))
+    {
+      type = g_boxed_type_register_static ("GFileList",
+                                           (GBoxedCopyFunc) g_file_list_copy,
+                                           (GBoxedFreeFunc) g_file_list_free);
+    }
+
+  return type;
+}

Modified: thunar/branches/migration-to-gio/thunar/thunar-gio-extensions.h
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-gio-extensions.h	2009-04-20 21:22:31 UTC (rev 29873)
+++ thunar/branches/migration-to-gio/thunar/thunar-gio-extensions.h	2009-04-21 10:08:08 UTC (rev 29874)
@@ -42,6 +42,16 @@
 
 gchar   *g_file_size_humanize        (guint64      size);
 
+/**
+ * G_TYPE_FILE_LIST:
+ *
+ * Returns the type ID for #GList<!---->s of #GFile<!---->s which is a 
+ * boxed type.
+ **/
+#define G_TYPE_FILE_LIST (g_file_list_get_type ())
+
+GType g_file_list_get_type (void);
+
 G_END_DECLS
 
 #endif /* !__THUNAR_GLIB_EXTENSIONS_H__ */




More information about the Xfce4-commits mailing list