[glib] GDBus: Sink closures in _with_closures functions



commit 1ed105b19b31bd5265de7d62156732b343c086e3
Author: Jürg Billeter <j bitron ch>
Date:   Fri Jun 18 23:48:28 2010 +0200

    GDBus: Sink closures in _with_closures functions
    
    See https://bugzilla.gnome.org/show_bug.cgi?id=621092#c12
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 gio/gdbusnameowning.c   |   25 ++++++++++++++++++++-----
 gio/gdbusnamewatching.c |   20 ++++++++++++++++----
 2 files changed, 36 insertions(+), 9 deletions(-)
---
diff --git a/gio/gdbusnameowning.c b/gio/gdbusnameowning.c
index 576d144..ba3afb9 100644
--- a/gio/gdbusnameowning.c
+++ b/gio/gdbusnameowning.c
@@ -737,13 +737,22 @@ g_bus_own_name_with_closures (GBusType                  bus_type,
   data = g_new0 (OwnNameData, 1);
 
   if (bus_acquired_closure != NULL)
-    data->bus_acquired_closure = g_closure_ref (bus_acquired_closure);
+    {
+      data->bus_acquired_closure = g_closure_ref (bus_acquired_closure);
+      g_closure_sink (bus_acquired_closure);
+    }
 
   if (name_acquired_closure != NULL)
-    data->name_acquired_closure = g_closure_ref (name_acquired_closure);
+    {
+      data->name_acquired_closure = g_closure_ref (name_acquired_closure);
+      g_closure_sink (name_acquired_closure);
+    }
 
   if (name_lost_closure != NULL)
-    data->name_lost_closure = g_closure_ref (name_lost_closure);
+    {
+      data->name_lost_closure = g_closure_ref (name_lost_closure);
+      g_closure_sink (name_lost_closure);
+    }
 
   return g_bus_own_name (bus_type,
           name,
@@ -787,10 +796,16 @@ g_bus_own_name_on_connection_with_closures (GDBusConnection          *connection
   data = g_new0 (OwnNameData, 1);
 
   if (name_acquired_closure != NULL)
-    data->name_acquired_closure = g_closure_ref (name_acquired_closure);
+    {
+      data->name_acquired_closure = g_closure_ref (name_acquired_closure);
+      g_closure_sink (name_acquired_closure);
+    }
 
   if (name_lost_closure != NULL)
-    data->name_lost_closure = g_closure_ref (name_lost_closure);
+    {
+      data->name_lost_closure = g_closure_ref (name_lost_closure);
+      g_closure_sink (name_lost_closure);
+    }
 
   return g_bus_own_name_on_connection (connection,
           name,
diff --git a/gio/gdbusnamewatching.c b/gio/gdbusnamewatching.c
index cb087a8..0e131fb 100644
--- a/gio/gdbusnamewatching.c
+++ b/gio/gdbusnamewatching.c
@@ -739,10 +739,16 @@ g_bus_watch_name_with_closures (GBusType                 bus_type,
   data = g_new0 (WatchNameData, 1);
 
   if (name_appeared_closure != NULL)
-    data->name_appeared_closure = g_closure_ref (name_appeared_closure);
+    {
+      data->name_appeared_closure = g_closure_ref (name_appeared_closure);
+      g_closure_sink (name_appeared_closure);
+    }
 
   if (name_vanished_closure != NULL)
-    data->name_vanished_closure = g_closure_ref (name_vanished_closure);
+    {
+      data->name_vanished_closure = g_closure_ref (name_vanished_closure);
+      g_closure_sink (name_vanished_closure);
+    }
 
   return g_bus_watch_name (bus_type,
           name,
@@ -785,10 +791,16 @@ guint g_bus_watch_name_on_connection_with_closures (
   data = g_new0 (WatchNameData, 1);
 
   if (name_appeared_closure != NULL)
-    data->name_appeared_closure = g_closure_ref (name_appeared_closure);
+    {
+      data->name_appeared_closure = g_closure_ref (name_appeared_closure);
+      g_closure_sink (name_appeared_closure);
+    }
 
   if (name_vanished_closure != NULL)
-    data->name_vanished_closure = g_closure_ref (name_vanished_closure);
+    {
+      data->name_vanished_closure = g_closure_ref (name_vanished_closure);
+      g_closure_sink (name_vanished_closure);
+    }
 
   return g_bus_watch_name_on_connection (connection,
           name,



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