mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 15:56:23 +01:00
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:
parent
1c6cd5f0a3
commit
a17e1e6d19
@ -569,6 +569,7 @@ struct _GTask {
|
|||||||
gboolean boolean;
|
gboolean boolean;
|
||||||
} result;
|
} result;
|
||||||
GDestroyNotify result_destroy;
|
GDestroyNotify result_destroy;
|
||||||
|
gboolean had_error;
|
||||||
gboolean result_set;
|
gboolean result_set;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1497,6 +1498,7 @@ g_task_propagate_error (GTask *task,
|
|||||||
{
|
{
|
||||||
g_propagate_error (error, task->error);
|
g_propagate_error (error, task->error);
|
||||||
task->error = NULL;
|
task->error = NULL;
|
||||||
|
task->had_error = TRUE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1793,7 +1795,7 @@ g_task_return_error_if_cancelled (GTask *task)
|
|||||||
gboolean
|
gboolean
|
||||||
g_task_had_error (GTask *task)
|
g_task_had_error (GTask *task)
|
||||||
{
|
{
|
||||||
if (task->error != NULL)
|
if (task->error != NULL || task->had_error)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (task->check_cancellable && g_cancellable_is_cancelled (task->cancellable))
|
if (task->check_cancellable && g_cancellable_is_cancelled (task->cancellable))
|
||||||
|
Loading…
Reference in New Issue
Block a user