[glib] gcancellable: don't use g_cancellable_connect() in GCancellableSource



commit fff14a5b7cf62d176b20bb3bb2fa573f9f7bcd2d
Author: Dan Winship <danw gnome org>
Date:   Sat Nov 2 09:33:26 2013 -0400

    gcancellable: don't use g_cancellable_connect() in GCancellableSource
    
    g_cancellable_connect() is documented as calling its callback only
    once, but GCancellableSource should trigger every time the cancellable
    is cancelled.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710691
    https://bugzilla.gnome.org/show_bug.cgi?id=711286

 gio/gcancellable.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/gio/gcancellable.c b/gio/gcancellable.c
index 0bbbf4b..2e3b4a0 100644
--- a/gio/gcancellable.c
+++ b/gio/gcancellable.c
@@ -736,11 +736,16 @@ g_cancellable_source_new (GCancellable *cancellable)
   if (cancellable)
     {
       cancellable_source->cancellable = g_object_ref (cancellable);
+
+      /* We intentionally don't use g_cancellable_connect() here,
+       * because we don't want the "at most once" behavior.
+       */
       cancellable_source->cancelled_handler =
-          g_cancellable_connect (cancellable,
-                                 G_CALLBACK (cancellable_source_cancelled),
-                                 source,
-                                 NULL);
+        g_signal_connect (cancellable, "cancelled",
+                          G_CALLBACK (cancellable_source_cancelled),
+                          source);
+      if (g_cancellable_is_cancelled (cancellable))
+        g_source_set_ready_time (source, 0);
     }
 
   return source;


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