Merge lp:~mhr3/libzeitgeist/no-lingering into lp:libzeitgeist

Proposed by Michal Hruby
Status: Merged
Approved by: Mikkel Kamstrup Erlandsen
Approved revision: 228
Merged at revision: 228
Proposed branch: lp:~mhr3/libzeitgeist/no-lingering
Merge into: lp:libzeitgeist
Diff against target: 113 lines (+13/-54)
1 file modified
src/zeitgeist-log.c (+13/-54)
To merge this branch: bzr merge lp:~mhr3/libzeitgeist/no-lingering
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen Approve
Review via email: mp+99291@code.launchpad.net

Description of the change

The way we used watch_name combined with the delayed dispatching of dbus method calls caused that if Zeitgeist isn't installed on the system, all the async calls just lingered indefinitely instead of returning an error.

This branch fixes that behaviour.

To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Looks correct. Liking the diffstat!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/zeitgeist-log.c'
2--- src/zeitgeist-log.c 2012-02-13 11:07:20 +0000
3+++ src/zeitgeist-log.c 2012-03-26 11:29:53 +0000
4@@ -53,9 +53,6 @@
5 /* Our connection to the bus */
6 GDBusConnection *connection;
7
8- /* Handle for our bus watcher, looking out for the zg daemon */
9- guint watcher_id;
10-
11 /* The connection to the ZG daemon.
12 * If log != NULL it means we have a connection */
13 GDBusProxy *log;
14@@ -94,11 +91,6 @@
15 gpointer user_data;
16 } MethodDispatchContext;
17
18-static void _zeitgeist_log_on_zg_appeared (GDBusConnection *connection,
19- const gchar *name,
20- const gchar *name_owner,
21- gpointer user_data);
22-
23 static void _zeitgeist_log_on_name_owner_changed (GObject *proxy,
24 GParamSpec *pspec,
25 gpointer user_data);
26@@ -137,13 +129,15 @@
27 priv->monitors = g_hash_table_new (g_direct_hash, g_direct_equal);
28
29 /* Set up the connection to the ZG daemon */
30- priv->watcher_id = g_bus_watch_name (G_BUS_TYPE_SESSION,
31- "org.gnome.zeitgeist.Engine",
32- G_BUS_NAME_WATCHER_FLAGS_AUTO_START,
33- _zeitgeist_log_on_zg_appeared,
34- NULL,
35- self,
36- NULL);
37+ g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
38+ G_DBUS_PROXY_FLAGS_NONE,
39+ NULL,
40+ "org.gnome.zeitgeist.Engine",
41+ "/org/gnome/zeitgeist/log/activity",
42+ "org.gnome.zeitgeist.Log",
43+ NULL,
44+ _zeitgeist_log_on_zg_proxy_acquired,
45+ g_object_ref (self));
46 }
47
48 static void
49@@ -160,12 +154,6 @@
50 priv->connection = NULL;
51 }
52
53- if (priv->watcher_id)
54- {
55- g_bus_unwatch_name (priv->watcher_id);
56- priv->watcher_id = 0;
57- }
58-
59 if (priv->log)
60 {
61 g_object_unref (priv->log);
62@@ -1050,40 +1038,8 @@
63 return TRUE;
64 }
65
66-/* Called when the Zeitgeist daemon enters the bus */
67-static void
68-_zeitgeist_log_on_zg_appeared (GDBusConnection *connection,
69- const gchar *name,
70- const gchar *name_owner,
71- gpointer user_data)
72-{
73- ZeitgeistLog *self;
74- ZeitgeistLogPrivate *priv;
75-
76- self = ZEITGEIST_LOG (user_data);
77- priv = ZEITGEIST_LOG_GET_PRIVATE (self);
78-
79- if (priv->connection == NULL)
80- {
81- priv->connection = g_object_ref (connection);
82- }
83-
84- if (priv->log == NULL)
85- {
86- g_dbus_proxy_new (connection,
87- G_DBUS_PROXY_FLAGS_NONE,
88- NULL,
89- name,
90- "/org/gnome/zeitgeist/log/activity",
91- "org.gnome.zeitgeist.Log",
92- NULL,
93- _zeitgeist_log_on_zg_proxy_acquired,
94- g_object_ref (self));
95- }
96-}
97-
98 /* Async callback for when a proxy is ready
99- * - triggered from _zeitgeist_log_on_zg_appeared */
100+ * - triggered from zeitgeist_log_init */
101 static void
102 _zeitgeist_log_on_zg_proxy_acquired (GObject *source_object,
103 GAsyncResult *res,
104@@ -1118,6 +1074,9 @@
105 goto cleanup;
106 }
107
108+ priv->connection = G_DBUS_CONNECTION (g_object_ref (
109+ g_dbus_proxy_get_connection (priv->log)));
110+
111 version_property = g_dbus_proxy_get_cached_property (priv->log, "version");
112 if (version_property)
113 {

Subscribers

People subscribed via source and target branches