[Telepathy-commits] [telepathy-glib/master] list-connections example: use tp_dbus_daemon_dup and fix cleanup code
Simon McVittie
simon.mcvittie at collabora.co.uk
Fri Jan 30 07:14:18 PST 2009
---
examples/client/list-connections.c | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/examples/client/list-connections.c b/examples/client/list-connections.c
index c655efb..748a2c1 100644
--- a/examples/client/list-connections.c
+++ b/examples/client/list-connections.c
@@ -60,16 +60,31 @@ main (int argc,
{
ExampleData data = { g_main_loop_new (NULL, FALSE), 0 };
TpDBusDaemon *bus_daemon;
+ GError *error = NULL;
g_type_init ();
tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG"));
- bus_daemon = tp_dbus_daemon_new (tp_get_bus ());
+ bus_daemon = tp_dbus_daemon_dup (&error);
+
+ if (bus_daemon == NULL)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ data.exit_code = 1;
+ goto out;
+ }
tp_list_connection_names (bus_daemon, got_connections, &data, NULL, NULL);
g_main_loop_run (data.mainloop);
- g_main_loop_unref (data.mainloop);
- g_object_unref (bus_daemon);
+
+out:
+ if (data.mainloop != NULL)
+ g_main_loop_unref (data.mainloop);
+
+ if (bus_daemon != NULL)
+ g_object_unref (bus_daemon);
+
return data.exit_code;
}
--
1.5.6.5
More information about the telepathy-commits
mailing list