Use g_task_return in task threads

This commit is contained in:
Khalid Abu Shawarib 2023-10-12 12:27:28 +00:00 committed by Michael Catanzaro
parent 20b0d292ca
commit dc0af83486
2 changed files with 12 additions and 14 deletions

View File

@ -568,6 +568,8 @@ dispatch_in_thread_func (GTask *task,
if (object != NULL) if (object != NULL)
g_object_unref (object); g_object_unref (object);
g_task_return_boolean (task, TRUE);
} }
static void static void

View File

@ -6774,8 +6774,6 @@ g_file_real_set_display_name_finish (GFile *file,
typedef struct { typedef struct {
GFileQueryInfoFlags flags; GFileQueryInfoFlags flags;
GFileInfo *info; GFileInfo *info;
gboolean res;
GError *error;
} SetInfoAsyncData; } SetInfoAsyncData;
static void static void
@ -6783,8 +6781,6 @@ set_info_data_free (SetInfoAsyncData *data)
{ {
if (data->info) if (data->info)
g_object_unref (data->info); g_object_unref (data->info);
if (data->error)
g_error_free (data->error);
g_free (data); g_free (data);
} }
@ -6795,13 +6791,16 @@ set_info_async_thread (GTask *task,
GCancellable *cancellable) GCancellable *cancellable)
{ {
SetInfoAsyncData *data = task_data; SetInfoAsyncData *data = task_data;
GError *error = NULL;
data->error = NULL; if (g_file_set_attributes_from_info (G_FILE (object),
data->res = g_file_set_attributes_from_info (G_FILE (object), data->info,
data->info, data->flags,
data->flags, cancellable,
cancellable, &error))
&data->error); g_task_return_boolean (task, TRUE);
else
g_task_return_error (task, error);
} }
static void static void
@ -6844,10 +6843,7 @@ g_file_real_set_attributes_finish (GFile *file,
if (info) if (info)
*info = g_object_ref (data->info); *info = g_object_ref (data->info);
if (error != NULL && data->error) return g_task_propagate_boolean (G_TASK (res), error);
*error = g_error_copy (data->error);
return data->res;
} }
static void static void