diff options
author | Ted Gould <ted@canonical.com> | 2009-06-18 16:54:25 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-06-18 16:54:25 -0500 |
commit | f56565b09f6747442f94f0218466f1a3d6b8869d (patch) | |
tree | 53aa68936539df53fe04511bf95be0d78ce85137 /libdbusmenu-glib | |
parent | 6b29e7e5a258644cc0c82963aab5d167748f8af2 (diff) | |
download | libdbusmenu-f56565b09f6747442f94f0218466f1a3d6b8869d.tar.gz libdbusmenu-f56565b09f6747442f94f0218466f1a3d6b8869d.tar.bz2 libdbusmenu-f56565b09f6747442f94f0218466f1a3d6b8869d.zip |
Handle the server removing itself from the bus and putting us into a dark world waiting for it to rejoin the world.
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r-- | libdbusmenu-glib/client.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index fec495d..043bf43 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -340,6 +340,27 @@ build_dbus_proxy (DbusmenuClient * client) return; } +/* A signal handler that gets called when a proxy is destoryed a + so it needs to clean up a little. Make sure we don't think we + have a layout and setup the dbus watcher. */ +static void +proxy_destroyed (GObject * gobj_proxy, gpointer userdata) +{ + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(userdata); + + if (priv->root != NULL) { + g_object_unref(G_OBJECT(priv->root)); + priv->root = NULL; + } + + if ((gpointer)priv->menuproxy == (gpointer)gobj_proxy) { + priv->layoutcall = NULL; + } + + build_dbus_proxy(DBUSMENU_CLIENT(userdata)); + return; +} + /* When we have a name and an object, build the two proxies and get the first version of the layout */ static void @@ -369,7 +390,8 @@ build_proxies (DbusmenuClient * client) g_error_free(error); return; } - // g_signal_connect(G_OBJECT(priv->propproxy), "destroy", proxy_destroyed, client); + g_object_add_weak_pointer(G_OBJECT(priv->propproxy), (gpointer *)&priv->propproxy); + g_signal_connect(G_OBJECT(priv->propproxy), "destroy", G_CALLBACK(proxy_destroyed), client); priv->menuproxy = dbus_g_proxy_new_for_name_owner(priv->session_bus, priv->dbus_name, @@ -381,7 +403,8 @@ build_proxies (DbusmenuClient * client) g_error_free(error); return; } - // g_signal_connect(G_OBJECT(priv->menuproxy), "destroy", proxy_destroyed, client); + g_object_add_weak_pointer(G_OBJECT(priv->menuproxy), (gpointer *)&priv->menuproxy); + g_signal_connect(G_OBJECT(priv->menuproxy), "destroy", G_CALLBACK(proxy_destroyed), client); /* If we get here, we don't need the DBus proxy */ if (priv->dbusproxy != NULL) { |