diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2009-09-15 18:11:16 +0800 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2009-09-15 18:11:16 +0800 |
commit | 93bc2c62fc9ae522b2d23d7354d0881936c72faa (patch) | |
tree | 6160f79082b370b36b57653e2efbcee8011aa93f /libempathy/empathy-handler.c | |
parent | c490644841baa24bb39e6078ebd121f3883c1b2f (diff) | |
download | gsoc2013-empathy-93bc2c62fc9ae522b2d23d7354d0881936c72faa.tar gsoc2013-empathy-93bc2c62fc9ae522b2d23d7354d0881936c72faa.tar.gz gsoc2013-empathy-93bc2c62fc9ae522b2d23d7354d0881936c72faa.tar.bz2 gsoc2013-empathy-93bc2c62fc9ae522b2d23d7354d0881936c72faa.tar.lz gsoc2013-empathy-93bc2c62fc9ae522b2d23d7354d0881936c72faa.tar.xz gsoc2013-empathy-93bc2c62fc9ae522b2d23d7354d0881936c72faa.tar.zst gsoc2013-empathy-93bc2c62fc9ae522b2d23d7354d0881936c72faa.zip |
Release the busname on disposal.
Diffstat (limited to 'libempathy/empathy-handler.c')
-rw-r--r-- | libempathy/empathy-handler.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/libempathy/empathy-handler.c b/libempathy/empathy-handler.c index 9a597889e..8374a00a1 100644 --- a/libempathy/empathy-handler.c +++ b/libempathy/empathy-handler.c @@ -46,9 +46,12 @@ typedef struct gpointer channels_user_data; gchar *name; + gchar *busname; GPtrArray *filters; GStrv *capabilities; + + gboolean dispose_run; } EmpathyHandlerPriv; static void empathy_handler_client_handler_iface_init (gpointer g_iface, @@ -89,25 +92,23 @@ handler_constructor (GType type, EmpathyHandler *handler = EMPATHY_HANDLER (obj); EmpathyHandlerPriv *priv = GET_PRIV (handler); TpDBusDaemon *dbus; - gchar *busname; gchar *object_path; priv = GET_PRIV (handler); - busname = g_strdup_printf (TP_CLIENT_BUS_NAME_BASE"%s", priv->name); + priv->busname = g_strdup_printf (TP_CLIENT_BUS_NAME_BASE"%s", priv->name); object_path = g_strdup_printf (TP_CLIENT_OBJECT_PATH_BASE"%s", priv->name); dbus = tp_dbus_daemon_dup (NULL); g_assert (tp_dbus_daemon_request_name (dbus, - busname, TRUE, NULL)); + priv->busname, TRUE, NULL)); dbus_g_connection_register_g_object (tp_get_bus (), object_path, obj); DEBUG ("Registered at '%s'", object_path); - g_free (busname); g_free (object_path); g_object_unref (dbus); @@ -115,6 +116,27 @@ handler_constructor (GType type, } static void +handler_dispose (GObject *object) +{ + EmpathyHandlerPriv *priv = GET_PRIV (object); + TpDBusDaemon *dbus; + + if (priv->dispose_run) + return; + + priv->dispose_run = TRUE; + + dbus = tp_dbus_daemon_dup (NULL); + + tp_dbus_daemon_release_name (dbus, priv->busname, NULL); + + g_object_unref (dbus); + + if (G_OBJECT_CLASS (empathy_handler_parent_class)->dispose != NULL) + G_OBJECT_CLASS (empathy_handler_parent_class)->dispose (object); +} + +static void handler_finalize (GObject *object) { EmpathyHandlerPriv *priv = GET_PRIV (object); @@ -126,6 +148,10 @@ handler_finalize (GObject *object) g_boxed_free (G_TYPE_STRV, priv->capabilities); g_free (priv->name); + g_free (priv->busname); + + if (G_OBJECT_CLASS (empathy_handler_parent_class)->finalize != NULL) + G_OBJECT_CLASS (empathy_handler_parent_class)->finalize (object); } static void @@ -243,6 +269,7 @@ empathy_handler_class_init (EmpathyHandlerClass *klass) }; object_class->finalize = handler_finalize; + object_class->dispose = handler_dispose; object_class->constructor = handler_constructor; object_class->get_property = handler_get_property; |