Commit 7ba4268d authored by Federico Mena Quintero's avatar Federico Mena Quintero Committed by Federico Mena Quintero

Factor out function to discard the loading process and the current folder file

	(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: 's avatarFederico Mena Quintero <federico@novell.com>

svn path=/trunk/; revision=22181
parent fe636e4b
......@@ -36,6 +36,14 @@
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>
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment