Pass refresh errors from the very bottom of the loading sequence up to the top

(start_loading_current_folder): Check if the folder to be loaded
	is non-native for the local_only=TRUE case; if so, return an error
	as we are configured to load only local folders.
	(reload_current_folder): Pass on errors from
	start_loading_current_folder().  Tighten the preconditions, as we
	are sure that we can only receive non-NULL folder-files to load.
	(refresh_current_folder_and_file_part): Pass on errors from
	reload_current_folder().  At the very end, assert the invariant
	described above.

Signed-off-by: Federico Mena Quintero <federico@novell.com>

svn path=/trunk/; revision=22182
This commit is contained in:
Federico Mena Quintero 2009-01-23 00:54:37 +00:00 committed by Federico Mena Quintero
parent 7ba4268d6b
commit cabc9f7f5c
2 changed files with 56 additions and 15 deletions

View File

@ -44,6 +44,15 @@
(reload_current_folder): Likewise. (reload_current_folder): Likewise.
(refresh_current_folder_and_file_part): Likewise, and ensure that (refresh_current_folder_and_file_part): Likewise, and ensure that
the error cases result in the invariant being held. the error cases result in the invariant being held.
(start_loading_current_folder): Check if the folder to be loaded
is non-native for the local_only=TRUE case; if so, return an error
as we are configured to load only local folders.
(reload_current_folder): Pass on errors from
start_loading_current_folder(). Tighten the preconditions, as we
are sure that we can only receive non-NULL folder-files to load.
(refresh_current_folder_and_file_part): Pass on errors from
reload_current_folder(). At the very end, assert the invariant
described above.
2009-01-22 Matthew Barnes <mbarnes@redhat.com> 2009-01-22 Matthew Barnes <mbarnes@redhat.com>
@ -92,6 +101,15 @@
for some locales. It should not be that necessary, now that we for some locales. It should not be that necessary, now that we
do show preedit text even in password entries. Pointed out by do show preedit text even in password entries. Pointed out by
Frederic Crozat. Frederic Crozat.
(start_loading_current_folder): Check if the folder to be loaded
is non-native for the local_only=TRUE case; if so, return an error
as we are configured to load only local folders.
(reload_current_folder): Pass on errors from
start_loading_current_folder(). Tighten the preconditions, as we
are sure that we can only receive non-NULL folder-files to load.
(refresh_current_folder_and_file_part): Pass on errors from
reload_current_folder(). At the very end, assert the invariant
described above.
2009-01-21 Federico Mena Quintero <federico@novell.com> 2009-01-21 Federico Mena Quintero <federico@novell.com>

View File

@ -1432,19 +1432,24 @@ out:
g_object_unref (cancellable); g_object_unref (cancellable);
} }
static void static RefreshStatus
start_loading_current_folder (GtkFileChooserEntry *chooser_entry) start_loading_current_folder (GtkFileChooserEntry *chooser_entry)
{ {
if (chooser_entry->current_folder_file == NULL || if (chooser_entry->file_system == NULL)
chooser_entry->file_system == NULL) return REFRESH_OK;
return;
g_assert (chooser_entry->current_folder_file != NULL);
g_assert (chooser_entry->current_folder == NULL);
g_assert (chooser_entry->load_folder_cancellable == NULL);
if (chooser_entry->local_only if (chooser_entry->local_only
&& !g_file_is_native (chooser_entry->current_folder_file)) && !g_file_is_native (chooser_entry->current_folder_file))
return; {
g_object_unref (chooser_entry->current_folder_file);
chooser_entry->current_folder_file = NULL;
g_assert (chooser_entry->current_folder == NULL); return REFRESH_NOT_LOCAL;
g_assert (chooser_entry->load_folder_cancellable == NULL); }
chooser_entry->load_folder_cancellable = chooser_entry->load_folder_cancellable =
_gtk_file_system_get_folder (chooser_entry->file_system, _gtk_file_system_get_folder (chooser_entry->file_system,
@ -1452,18 +1457,22 @@ start_loading_current_folder (GtkFileChooserEntry *chooser_entry)
"standard::name,standard::display-name,standard::type", "standard::name,standard::display-name,standard::type",
load_directory_get_folder_callback, load_directory_get_folder_callback,
g_object_ref (chooser_entry)); g_object_ref (chooser_entry));
return REFRESH_OK;
} }
static void static RefreshStatus
reload_current_folder (GtkFileChooserEntry *chooser_entry, reload_current_folder (GtkFileChooserEntry *chooser_entry,
GFile *folder_file, GFile *folder_file,
gboolean force_reload) gboolean force_reload)
{ {
gboolean reload = FALSE; gboolean reload = FALSE;
g_assert (folder_file != NULL);
if (chooser_entry->current_folder_file) if (chooser_entry->current_folder_file)
{ {
if ((folder_file && !(g_file_equal (folder_file, chooser_entry->current_folder_file) if ((!(g_file_equal (folder_file, chooser_entry->current_folder_file)
&& chooser_entry->load_folder_cancellable)) && chooser_entry->load_folder_cancellable))
|| force_reload) || force_reload)
{ {
@ -1472,17 +1481,19 @@ reload_current_folder (GtkFileChooserEntry *chooser_entry,
discard_current_folder (chooser_entry); discard_current_folder (chooser_entry);
discard_loading_and_current_folder_file (chooser_entry); discard_loading_and_current_folder_file (chooser_entry);
chooser_entry->current_folder_file = (folder_file) ? g_object_ref (folder_file) : NULL; chooser_entry->current_folder_file = g_object_ref (folder_file);
} }
} }
else else
{ {
chooser_entry->current_folder_file = (folder_file) ? g_object_ref (folder_file) : NULL; chooser_entry->current_folder_file = g_object_ref (folder_file);
reload = TRUE; reload = TRUE;
} }
if (reload) if (reload)
start_loading_current_folder (chooser_entry); return start_loading_current_folder (chooser_entry);
else
return REFRESH_OK;
} }
static RefreshStatus static RefreshStatus
@ -1548,6 +1559,8 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry,
} }
else else
{ {
g_assert (folder_file != NULL);
file_part_len = strlen (file_part); file_part_len = strlen (file_part);
total_len = strlen (text); total_len = strlen (text);
if (total_len > file_part_len) if (total_len > file_part_len)
@ -1567,8 +1580,7 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry,
if (result == REFRESH_OK) if (result == REFRESH_OK)
{ {
/* FMQ: this needs to return an error if the folder is not local */ result = reload_current_folder (chooser_entry, folder_file, file_part_pos == -1);
reload_current_folder (chooser_entry, folder_file, file_part_pos == -1);
} }
else else
{ {
@ -1579,6 +1591,17 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry,
if (folder_file) if (folder_file)
g_object_unref (folder_file); g_object_unref (folder_file);
g_assert (/* we are OK and we have a current folder file and (loading process or folder handle)... */
((result == REFRESH_OK)
&& (chooser_entry->current_folder_file != NULL)
&& (((chooser_entry->load_folder_cancellable != NULL) && (chooser_entry->current_folder == NULL))
|| ((chooser_entry->load_folder_cancellable == NULL) && (chooser_entry->current_folder != NULL))))
/* ... OR we have an error, and we don't have a current folder file nor a loading process nor a folder handle */
|| ((result != REFRESH_OK)
&& (chooser_entry->current_folder_file == NULL)
&& (chooser_entry->load_folder_cancellable == NULL)
&& (chooser_entry->current_folder == NULL)));
return result; return result;
} }