aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libindicator/indicator-service.c17
-rw-r--r--tests/service-version-good-service.c15
2 files changed, 30 insertions, 2 deletions
diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c
index db234e2..d0f8ed2 100644
--- a/libindicator/indicator-service.c
+++ b/libindicator/indicator-service.c
@@ -395,14 +395,26 @@ try_and_get_name (IndicatorService * service)
return;
}
+/* Look in the hash table for the proxy, as it won't give us
+ its name. */
+static gboolean
+hash_table_find (gpointer key, gpointer value, gpointer user_data)
+{
+ if (value == user_data) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
/* If the proxy gets destroyed that's the same as getting an
unwatch signal. Make it so. */
static void
proxy_destroyed (GObject * proxy, gpointer user_data)
{
g_return_if_fail(INDICATOR_IS_SERVICE(user_data));
+ IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(user_data);
- const gchar * name = dbus_g_proxy_get_bus_name(DBUS_G_PROXY(proxy));
+ gchar * name = (gchar *)g_hash_table_find(priv->watchers, hash_table_find, proxy);
unwatch_core(INDICATOR_SERVICE(user_data), name);
return;
@@ -466,6 +478,9 @@ _indicator_service_server_un_watch (IndicatorService * service, DBusGMethodInvoc
static void
unwatch_core (IndicatorService * service, const gchar * name)
{
+ g_return_if_fail(name != NULL);
+ g_return_if_fail(INDICATOR_IS_SERVICE(service));
+
IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(service);
/* Remove us from the watcher list here */
diff --git a/tests/service-version-good-service.c b/tests/service-version-good-service.c
index bcfe46d..12a6a32 100644
--- a/tests/service-version-good-service.c
+++ b/tests/service-version-good-service.c
@@ -5,12 +5,19 @@
static GMainLoop * mainloop = NULL;
static gboolean passed = FALSE;
+static IndicatorService * is = NULL;
gboolean
timeout (gpointer data)
{
passed = FALSE;
g_debug("Timeout with no shutdown.");
+
+ if (is != NULL) {
+ g_object_unref(is);
+ is = NULL;
+ }
+
g_main_loop_quit(mainloop);
return FALSE;
}
@@ -20,6 +27,12 @@ shutdown (void)
{
g_debug("Shutdown");
passed = TRUE;
+
+ if (is != NULL) {
+ g_object_unref(is);
+ is = NULL;
+ }
+
g_main_loop_quit(mainloop);
return;
}
@@ -29,7 +42,7 @@ main (int argc, char ** argv)
{
g_type_init();
- IndicatorService * is = indicator_service_new_version("org.ayatana.version.good", SERVICE_VERSION_GOOD);
+ is = indicator_service_new_version("org.ayatana.version.good", SERVICE_VERSION_GOOD);
g_signal_connect(G_OBJECT(is), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, shutdown, NULL);
g_timeout_add_seconds(1, timeout, NULL);