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

Jannis Pohlmann jannis at xfce.org
Tue Apr 28 21:55:34 CEST 2009


Author: jannis
Date: 2009-04-28 19:55:34 +0000 (Tue, 28 Apr 2009)
New Revision: 29912

Modified:
   thunar/branches/migration-to-gio/ChangeLog
   thunar/branches/migration-to-gio/thunar/thunar-folder.c
   thunar/branches/migration-to-gio/thunar/thunar-io-jobs.c
   thunar/branches/migration-to-gio/thunar/thunar-io-scan-directory.c
   thunar/branches/migration-to-gio/thunar/thunar-job.c
   thunar/branches/migration-to-gio/thunar/thunar-window.c
Log:
	* thunar/thunar-io-jobs.c, thunar/thunar-io-scan-directory.c: Improve
	  error handling. Use thunar_file_list_free() instead of iterating over
	  the ThunarFile list manually. Make sure to release the
	  GFileEnumerator in thunar_io_scan_directory(), otherwise unmounting
	  volumes fails due to open file descriptors.
	* thunar/thunar-job.c: Cancel jobs in thunar_job_finalize() before
	  destroying the GCancellable.

Modified: thunar/branches/migration-to-gio/ChangeLog
===================================================================
--- thunar/branches/migration-to-gio/ChangeLog	2009-04-28 16:45:32 UTC (rev 29911)
+++ thunar/branches/migration-to-gio/ChangeLog	2009-04-28 19:55:34 UTC (rev 29912)
@@ -1,5 +1,15 @@
 2009-04-28	Jannis Pohlmann <jannis at xfce.org>
 
+	* thunar/thunar-io-jobs.c, thunar/thunar-io-scan-directory.c: Improve
+	  error handling. Use thunar_file_list_free() instead of iterating over
+	  the ThunarFile list manually. Make sure to release the
+	  GFileEnumerator in thunar_io_scan_directory(), otherwise unmounting
+	  volumes fails due to open file descriptors.
+	* thunar/thunar-job.c: Cancel jobs in thunar_job_finalize() before
+	  destroying the GCancellable.
+
+2009-04-28	Jannis Pohlmann <jannis at xfce.org>
+
 	* thunar/thunar-file.{c,h}: Make the ThunarFile cache somewhat 
 	  thread-safe.
 	* thunar/thunar-gio-extensions.{c,h}: Add new functions

Modified: thunar/branches/migration-to-gio/thunar/thunar-folder.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-folder.c	2009-04-28 16:45:32 UTC (rev 29911)
+++ thunar/branches/migration-to-gio/thunar/thunar-folder.c	2009-04-28 19:55:34 UTC (rev 29912)
@@ -261,14 +261,14 @@
   ThunarFolder *folder = THUNAR_FOLDER (object);
 
   /* disconnect from the ThunarFileMonitor instance */
-  g_signal_handlers_disconnect_matched (G_OBJECT (folder->file_monitor), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, folder);
-  g_object_unref (G_OBJECT (folder->file_monitor));
+  g_signal_handlers_disconnect_matched (folder->file_monitor, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, folder);
+  g_object_unref (folder->file_monitor);
 
   /* disconnect from the file alteration monitor */
   if (G_LIKELY (folder->monitor != NULL))
     {
       g_file_monitor_cancel (folder->monitor);
-      g_object_unref (G_OBJECT (folder->monitor));
+      g_object_unref (folder->monitor);
     }
 
   /* cancel the pending job (if any) */
@@ -276,7 +276,7 @@
     {
       g_signal_handlers_disconnect_matched (folder->job, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, folder);
       thunar_job_cancel (folder->job);
-      g_object_unref (G_OBJECT (folder->job));
+      g_object_unref (folder->job);
     }
 
   /* disconnect from the corresponding file */
@@ -730,7 +730,7 @@
       /* disconnect from the job */
       g_signal_handlers_disconnect_matched (folder->job, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, folder);
       thunar_job_cancel (THUNAR_JOB (folder->job));
-      g_object_unref (G_OBJECT (folder->job));
+      g_object_unref (folder->job);
     }
 
   /* disconnect from the file alteration monitor */

Modified: thunar/branches/migration-to-gio/thunar/thunar-io-jobs.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-io-jobs.c	2009-04-28 16:45:32 UTC (rev 29911)
+++ thunar/branches/migration-to-gio/thunar/thunar-io-jobs.c	2009-04-28 19:55:34 UTC (rev 29912)
@@ -999,6 +999,9 @@
   _thunar_return_val_if_fail (param_values->n_values == 1, FALSE);
   _thunar_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
+  if (thunar_job_set_error_if_cancelled (job, error))
+    return FALSE;
+
   /* determine the directory to list */
   directory = g_value_get_object (g_value_array_get_nth (param_values, 0));
 
@@ -1043,13 +1046,15 @@
         {
           /* none of the handlers took over the file list, so it's up to us
            * to destroy it */
-          g_list_foreach (file_list, (GFunc) g_object_unref, NULL);
-          g_list_free (file_list);
+          thunar_file_list_free (file_list);
         }
     }
   
-  /* check if there were any errors */
-  if (err != NULL)
+  /* there should be no errors here */
+  _thunar_assert (err == NULL);
+
+  /* propagate cancellation error */
+  if (thunar_job_set_error_if_cancelled (job, &err))
     {
       g_propagate_error (error, err);
       return FALSE;

Modified: thunar/branches/migration-to-gio/thunar/thunar-io-scan-directory.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-io-scan-directory.c	2009-04-28 16:45:32 UTC (rev 29911)
+++ thunar/branches/migration-to-gio/thunar/thunar-io-scan-directory.c	2009-04-28 19:55:34 UTC (rev 29912)
@@ -55,14 +55,14 @@
   /* query the file type */
   type = g_file_query_file_type (file, flags, thunar_job_get_cancellable (job));
 
+  /* abort if the job was cancelled */
+  if (thunar_job_set_error_if_cancelled (job, error))
+    return NULL;
+
   /* ignore non-directory nodes */
   if (type != G_FILE_TYPE_DIRECTORY)
     return NULL;
 
-  /* abort if the job was cancelled */
-  if (thunar_job_set_error_if_cancelled (job, error))
-    return NULL;
-
   /* try to read from the direectory */
   enumerator = g_file_enumerate_children (file,
                                           G_FILE_ATTRIBUTE_STANDARD_TYPE ","
@@ -103,19 +103,21 @@
       info = g_file_enumerator_next_file (enumerator, thunar_job_get_cancellable (job), &err);
     }
 
-  if (err != NULL)
+  /* release the enumerator */
+  g_object_unref (enumerator);
+
+  if (G_UNLIKELY (err != NULL))
     {
-      if (thunar_job_set_error_if_cancelled (job, error))
-        {
-          g_clear_error (&err);
-        }
-      else
-        g_propagate_error (error, err);
-
-      g_object_unref (enumerator);
+      g_propagate_error (error, err);
       g_file_list_free (files);
       return NULL;
     }
+  else if (thunar_job_set_error_if_cancelled (job, &err))
+    {
+      g_propagate_error (error, err);
+      g_file_list_free (files);
+      return NULL;
+    }
   
   return files;
 }

Modified: thunar/branches/migration-to-gio/thunar/thunar-job.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-job.c	2009-04-28 16:45:32 UTC (rev 29911)
+++ thunar/branches/migration-to-gio/thunar/thunar-job.c	2009-04-28 19:55:34 UTC (rev 29912)
@@ -345,6 +345,7 @@
 {
   ThunarJob *job = THUNAR_JOB (object);
 
+  thunar_job_cancel (job);
   g_object_unref (job->priv->cancellable);
 
   (*G_OBJECT_CLASS (thunar_job_parent_class)->finalize) (object);

Modified: thunar/branches/migration-to-gio/thunar/thunar-window.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-window.c	2009-04-28 16:45:32 UTC (rev 29911)
+++ thunar/branches/migration-to-gio/thunar/thunar-window.c	2009-04-28 19:55:34 UTC (rev 29912)
@@ -2552,7 +2552,7 @@
 
   _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
   _thunar_return_if_fail (current_directory == NULL || THUNAR_IS_FILE (current_directory));
-
+  
   /* check if we already display the requested directory */
   if (G_UNLIKELY (window->current_directory == current_directory))
     return;




More information about the Xfce4-commits mailing list