[glib] gtask: Don't forget about the error after g_task_propagate_*



commit a17e1e6d197745c0f0a59f72869f226b23e47d4f
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Mar 24 18:36:47 2016 +0100

    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 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/gio/gtask.c b/gio/gtask.c
index 5a1cfab..042e047 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))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]