aboutsummaryrefslogtreecommitdiff
path: root/libindicator/indicator-service.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-07-08 15:18:26 -0500
committerTed Gould <ted@gould.cx>2010-07-08 15:18:26 -0500
commit7957aca1b789f6b21531c64ba60b5ca1e3d371af (patch)
tree4a75270005317356d958af165fc35c0510d237c9 /libindicator/indicator-service.c
parent2b3087f569dc7f4db6bb94f48cdf902c4d402b6d (diff)
parent3b191f923fd4e31594898027b94cf6cc8a91cba9 (diff)
downloadlibayatana-indicator-7957aca1b789f6b21531c64ba60b5ca1e3d371af.tar.gz
libayatana-indicator-7957aca1b789f6b21531c64ba60b5ca1e3d371af.tar.bz2
libayatana-indicator-7957aca1b789f6b21531c64ba60b5ca1e3d371af.zip
New upstream release.
Diffstat (limited to 'libindicator/indicator-service.c')
-rw-r--r--libindicator/indicator-service.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c
index 15335f3..db234e2 100644
--- a/libindicator/indicator-service.c
+++ b/libindicator/indicator-service.c
@@ -30,6 +30,8 @@ License along with this library. If not, see
#include "indicator-service.h"
static void unwatch_core (IndicatorService * service, const gchar * name);
+static void proxy_destroyed (GObject * proxy, gpointer user_data);
+static gboolean watchers_remove (gpointer key, gpointer value, gpointer user_data);
/* DBus Prototypes */
static gboolean _indicator_service_server_watch (IndicatorService * service, DBusGMethodInvocation * method);
static gboolean _indicator_service_server_un_watch (IndicatorService * service, DBusGMethodInvocation * method);
@@ -163,6 +165,10 @@ indicator_service_init (IndicatorService *self)
priv->bus = NULL;
priv->this_service_version = 0;
+ /* NOTE: We're using g_object_unref here because that's what needs to
+ happen, but you really should call watchers_remove first as well
+ since that disconnects the signals. We can't do that with a callback
+ here because there is no user data to pass the object as well. */
priv->watchers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
/* Start talkin' dbus */
@@ -209,6 +215,10 @@ indicator_service_dispose (GObject *object)
{
IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(object);
+ if (priv->watchers != NULL) {
+ g_hash_table_foreach_remove(priv->watchers, watchers_remove, object);
+ }
+
if (priv->dbus_proxy != NULL) {
g_object_unref(G_OBJECT(priv->dbus_proxy));
priv->dbus_proxy = NULL;
@@ -314,6 +324,15 @@ get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspe
return;
}
+/* A function to remove the signals on a proxy before we destroy
+ it because in this case we've stopped caring. */
+static gboolean
+watchers_remove (gpointer key, gpointer value, gpointer user_data)
+{
+ g_signal_handlers_disconnect_by_func(G_OBJECT(value), G_CALLBACK(proxy_destroyed), user_data);
+ return TRUE;
+}
+
/* This is the function that gets executed if we timeout
because there are no watchers. We sent the shutdown
signal and hope someone does something sane with it. */
@@ -453,6 +472,7 @@ unwatch_core (IndicatorService * service, const gchar * name)
gpointer watcher_item = g_hash_table_lookup(priv->watchers, name);
if (watcher_item != NULL) {
/* Free the watcher */
+ watchers_remove((gpointer)name, watcher_item, service);
g_hash_table_remove(priv->watchers, name);
} else {
/* Odd that we couldn't find the person, but, eh */