[gnome-bluetooth] lib: Simplify agent finalization
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth] lib: Simplify agent finalization
- Date: Wed, 27 Oct 2010 20:03:02 +0000 (UTC)
commit 40d9e4273341bbf908b5877c5f345897ca7e9db6
Author: Bastien Nocera <hadess hadess net>
Date: Wed Oct 27 18:32:15 2010 +0100
lib: Simplify agent finalization
Turns out that we were doing pretty much the same thing in
unregister and in finalize.
lib/bluetooth-agent.c | 21 +++++++--------------
1 files changed, 7 insertions(+), 14 deletions(-)
---
diff --git a/lib/bluetooth-agent.c b/lib/bluetooth-agent.c
index 52298b6..900d781 100644
--- a/lib/bluetooth-agent.c
+++ b/lib/bluetooth-agent.c
@@ -322,21 +322,9 @@ static void bluetooth_agent_init(BluetoothAgent *agent)
static void bluetooth_agent_finalize(GObject *agent)
{
- BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
-
DBG("agent %p", agent);
- if (priv->adapter != NULL) {
- dbus_g_proxy_call(priv->adapter, "UnregisterAgent", NULL,
- DBUS_TYPE_G_OBJECT_PATH, priv->path,
- G_TYPE_INVALID, G_TYPE_INVALID);
-
- g_object_unref(priv->adapter);
- priv->adapter = NULL;
- }
-
- g_free(priv->path);
- g_free(priv->busname);
+ bluetooth_agent_unregister (BLUETOOTH_AGENT (agent));
G_OBJECT_CLASS(bluetooth_agent_parent_class)->finalize(agent);
}
@@ -472,13 +460,15 @@ gboolean bluetooth_agent_register(BluetoothAgent *agent, DBusGProxy *adapter)
gboolean bluetooth_agent_unregister(BluetoothAgent *agent)
{
- BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
+ BluetoothAgentPrivate *priv;
GError *error = NULL;
g_return_val_if_fail (BLUETOOTH_IS_AGENT (agent), FALSE);
DBG("agent %p", agent);
+ priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
+
if (priv->adapter == NULL)
return FALSE;
@@ -504,6 +494,9 @@ gboolean bluetooth_agent_unregister(BluetoothAgent *agent)
g_free(priv->path);
priv->path = NULL;
+ g_free(priv->busname);
+ priv->busname = NULL;
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]