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
This commit is contained in:
Debarshi Ray 2016-03-24 18:36:47 +01:00
parent 1c6cd5f0a3
commit a17e1e6d19

View File

@ -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))