diff options
author | David Zeuthen <davidz@redhat.com> | 2010-06-18 13:21:03 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2010-06-18 13:21:03 -0400 |
commit | 490757bfc60cad6079c121b8633c02151124794b (patch) | |
tree | 2954ceec46060eedf0d2acbe79bf192a8bfc7168 | |
parent | c035ac1bac4914794acc869acce9c1532434cb91 (diff) |
Free closures correctly
Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r-- | src/gdbusgi.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/gdbusgi.c b/src/gdbusgi.c index c543542..387a4a3 100644 --- a/src/gdbusgi.c +++ b/src/gdbusgi.c @@ -1055,19 +1055,22 @@ typedef struct InterfaceData *interface_data; - /* A list of GDBusClosure objects - one for each signal */ - GList *closures; + GArray *signal_handler_ids; } ExportData; static void export_data_free (ExportData *data) { - GList *l; - - for (l = data->closures; l != NULL; l = l->next) + if (data->signal_handler_ids != NULL) { - GClosure *closure = l->data; - g_closure_unref (closure); + guint n; + for (n = 0; n < data->signal_handler_ids->len; n++) + { + gulong id; + id = g_array_index (data->signal_handler_ids, gulong, n); + g_signal_handler_disconnect (data->object, id); + } + g_array_unref (data->signal_handler_ids); } if (data->object != NULL) g_object_unref (data->object); @@ -1082,7 +1085,6 @@ export_data_free (ExportData *data) interface_data_free (data->interface_data); #endif g_free (data); - g_debug ("blah"); } /* ---------------------------------------------------------------------------------------------------- */ @@ -1982,6 +1984,7 @@ g_dbus_connection_register_gobject (GDBusConnection *connection, goto fail; /* Set up signal handlers for all exported signals */ + data->signal_handler_ids = g_array_new (FALSE, FALSE, sizeof (gulong)); g_hash_table_iter_init (&iter, data->interface_data->g_signal_name_to_signal_data); while (g_hash_table_iter_next (&iter, (gpointer*) &g_signal_name, (gpointer*) &signal_data)) { @@ -1996,8 +1999,7 @@ g_dbus_connection_register_gobject (GDBusConnection *connection, (GClosure *) closure, TRUE); closure->export_data = data; - - data->closures = g_list_prepend (data->closures, closure); + g_array_append_val (data->signal_handler_ids, closure->signal_handler_id); } return g_dbus_connection_register_object (connection, |