]> Pileus Git - ~andy/gtk/commitdiff
Factor out function to discard the loading process and the current folder file
authorFederico Mena Quintero <federico@novell.com>
Fri, 23 Jan 2009 00:54:22 +0000 (00:54 +0000)
committerFederico Mena Quintero <federico@src.gnome.org>
Fri, 23 Jan 2009 00:54:22 +0000 (00:54 +0000)
(discard_loading_and_current_folder_file): Factor out function to
cancel the cancellable and discard the current_folder_file,
i.e. to reset the invariant to the "nothing valid is loaded" case.
(gtk_file_chooser_entry_dispose): Use
discard_loading_and_current_folder_file().
(reload_current_folder): Likewise.
(refresh_current_folder_and_file_part): Likewise, and ensure that
the error cases result in the invariant being held.

Signed-off-by: Federico Mena Quintero <federico@novell.com>
svn path=/trunk/; revision=22181

ChangeLog
gtk/gtkfilechooserentry.c

index bcbfc4b92610093d8a1f20f9b8b22200a3f948fd..3994cda49c78ba04fdc0f05ab9f064fc53d1b1b0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
        only do completion in the REFRESH_OK case.  For the error cases,
        we don't do anything, as this is autocompletion and must not
        result in non-asked-for errors popping up.
+       (discard_loading_and_current_folder_file): Factor out function to
+       cancel the cancellable and discard the current_folder_file,
+       i.e. to reset the invariant to the "nothing valid is loaded" case.
+       (gtk_file_chooser_entry_dispose): Use
+       discard_loading_and_current_folder_file().
+       (reload_current_folder): Likewise.
+       (refresh_current_folder_and_file_part): Likewise, and ensure that
+       the error cases result in the invariant being held.
        
 2009-01-22  Matthew Barnes  <mbarnes@redhat.com>
 
index de6adea7f75b2baf6af05fc36298a4a9d450c3aa..e1c884a62b280de5b914c231073a5119118877c7 100644 (file)
@@ -268,6 +268,22 @@ discard_current_folder (GtkFileChooserEntry *chooser_entry)
     }
 }
 
+static void
+discard_loading_and_current_folder_file (GtkFileChooserEntry *chooser_entry)
+{
+  if (chooser_entry->load_folder_cancellable)
+    {
+      g_cancellable_cancel (chooser_entry->load_folder_cancellable);
+      chooser_entry->load_folder_cancellable = NULL;
+    }
+
+  if (chooser_entry->current_folder_file)
+    {
+      g_object_unref (chooser_entry->current_folder_file);
+      chooser_entry->current_folder_file = NULL;
+    }
+}
+
 static void
 gtk_file_chooser_entry_dispose (GObject *object)
 {
@@ -275,6 +291,7 @@ gtk_file_chooser_entry_dispose (GObject *object)
 
   remove_completion_feedback (chooser_entry);
   discard_current_folder (chooser_entry);
+  discard_loading_and_current_folder_file (chooser_entry);
 
   if (chooser_entry->start_autocompletion_idle_id != 0)
     {
@@ -288,12 +305,6 @@ gtk_file_chooser_entry_dispose (GObject *object)
       chooser_entry->completion_store = NULL;
     }
 
-  if (chooser_entry->load_folder_cancellable)
-    {
-      g_cancellable_cancel (chooser_entry->load_folder_cancellable);
-      chooser_entry->load_folder_cancellable = NULL;
-    }
-
   if (chooser_entry->file_system)
     {
       g_object_unref (chooser_entry->file_system);
@@ -1458,17 +1469,9 @@ reload_current_folder (GtkFileChooserEntry *chooser_entry,
        {
          reload = TRUE;
 
-         /* We changed our current directory.  We need to clear out the old
-          * directory information.
-          */
-          if (chooser_entry->load_folder_cancellable)
-            {
-              g_cancellable_cancel (chooser_entry->load_folder_cancellable);
-              chooser_entry->load_folder_cancellable = NULL;
-            }
-
           discard_current_folder (chooser_entry);
-         g_object_unref (chooser_entry->current_folder_file);
+         discard_loading_and_current_folder_file (chooser_entry);
+
          chooser_entry->current_folder_file = (folder_file) ? g_object_ref (folder_file) : NULL;
        }
     }
@@ -1562,8 +1565,16 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry,
   chooser_entry->file_part = file_part;
   chooser_entry->file_part_pos = file_part_pos;
 
-  /* FMQ: this needs to return an error if the folder is not local */
-  reload_current_folder (chooser_entry, folder_file, file_part_pos == -1);
+  if (result == REFRESH_OK)
+    {
+      /* FMQ: this needs to return an error if the folder is not local */
+      reload_current_folder (chooser_entry, folder_file, file_part_pos == -1);
+    }
+  else
+    {
+      discard_current_folder (chooser_entry);
+      discard_loading_and_current_folder_file (chooser_entry);
+    }
 
   if (folder_file)
     g_object_unref (folder_file);