From a17e1e6d197745c0f0a59f72869f226b23e47d4f Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Thu, 24 Mar 2016 18:36:47 +0100 Subject: [PATCH] gtask: Don't forget about the error after g_task_propagate_* The use of past tense in g_task_had_error makes one assume that it won't forget about any errors that might have occurred. Except, in reality, it would. Let's use a boolean flag to remember the error once it's been propagated, as opposed to keeping the error around. This ensures that the g_task_propagate_* methods continue to give invalid results when called more than once, as mentioned in the documentation. https://bugzilla.gnome.org/show_bug.cgi?id=764163 --- gio/gtask.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gio/gtask.c b/gio/gtask.c index 5a1cfab4c..042e04764 100644 --- a/gio/gtask.c +++ b/gio/gtask.c @@ -569,6 +569,7 @@ struct _GTask { gboolean boolean; } result; GDestroyNotify result_destroy; + gboolean had_error; gboolean result_set; }; @@ -1497,6 +1498,7 @@ g_task_propagate_error (GTask *task, { g_propagate_error (error, task->error); task->error = NULL; + task->had_error = TRUE; return TRUE; } else @@ -1793,7 +1795,7 @@ g_task_return_error_if_cancelled (GTask *task) gboolean g_task_had_error (GTask *task) { - if (task->error != NULL) + if (task->error != NULL || task->had_error) return TRUE; if (task->check_cancellable && g_cancellable_is_cancelled (task->cancellable))