background: Fix handling of cancellation in async calls
A few of the async calls were still handling the user_data before checking that it was still valid (eg. the operation was not cancelled), and also printing warnings when the error was a cancellation.
This commit is contained in:
parent
c764fbe745
commit
f9c0732a6c
1 changed files with 12 additions and 5 deletions
|
@ -371,7 +371,7 @@ file_info_async_ready (GObject *source,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
BgPicturesSource *bg_source = BG_PICTURES_SOURCE (user_data);
|
||||
BgPicturesSource *bg_source;
|
||||
GList *files, *l;
|
||||
GError *err = NULL;
|
||||
GFile *parent;
|
||||
|
@ -381,7 +381,8 @@ file_info_async_ready (GObject *source,
|
|||
&err);
|
||||
if (err)
|
||||
{
|
||||
g_warning ("Could not get pictures file information: %s", err->message);
|
||||
if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
g_warning ("Could not get pictures file information: %s", err->message);
|
||||
g_error_free (err);
|
||||
|
||||
g_list_foreach (files, (GFunc) g_object_unref, NULL);
|
||||
|
@ -389,6 +390,8 @@ file_info_async_ready (GObject *source,
|
|||
return;
|
||||
}
|
||||
|
||||
bg_source = BG_PICTURES_SOURCE (user_data);
|
||||
|
||||
parent = g_file_enumerator_get_container (G_FILE_ENUMERATOR (source));
|
||||
|
||||
files = g_list_sort (files, file_sort_func);
|
||||
|
@ -413,7 +416,7 @@ dir_enum_async_ready (GObject *source,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
BgPicturesSourcePrivate *priv = BG_PICTURES_SOURCE (user_data)->priv;
|
||||
BgPicturesSourcePrivate *priv;
|
||||
GFileEnumerator *enumerator;
|
||||
GError *err = NULL;
|
||||
|
||||
|
@ -421,12 +424,15 @@ dir_enum_async_ready (GObject *source,
|
|||
|
||||
if (err)
|
||||
{
|
||||
if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) == FALSE)
|
||||
if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) &&
|
||||
!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
g_warning ("Could not fill pictures source: %s", err->message);
|
||||
g_error_free (err);
|
||||
return;
|
||||
}
|
||||
|
||||
priv = BG_PICTURES_SOURCE (user_data)->priv;
|
||||
|
||||
/* get the files */
|
||||
g_file_enumerator_next_files_async (enumerator,
|
||||
G_MAXINT,
|
||||
|
@ -537,7 +543,8 @@ file_info_ready (GObject *object,
|
|||
|
||||
if (!info)
|
||||
{
|
||||
g_warning ("Problem looking up file info: %s", error->message);
|
||||
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
g_warning ("Problem looking up file info: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue