From 5c8be87889353cf6fb5dc079fa2a1b9fe7393e62 Mon Sep 17 00:00:00 2001 From: Santiago Carot-Nemesio Date: Mon, 24 Oct 2011 19:04:07 +0200 Subject: [PATCH] Manage watcher's disconnections from the bus --- thermometer/thermometer.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c index 9513fcdfc..52f75350b 100644 --- a/thermometer/thermometer.c +++ b/thermometer/thermometer.c @@ -554,7 +554,16 @@ static void disable_final_measurement(struct thermometer *t) static void watcher_exit(DBusConnection *conn, void *user_data) { - /* TODO: Watcher disconnected */ + struct watcher *watcher = user_data; + struct thermometer *t = watcher->t; + + DBG("Thermometer watcher %s disconnected", watcher->path); + + t->fwatchers = g_slist_remove(t->fwatchers, watcher); + watcher->id = 0; + + if (g_slist_length(t->fwatchers) == 0) + disable_final_measurement(t); } static struct watcher *find_watcher(struct thermometer *t, const gchar *sender, -- 2.47.3