diff options
author | Ted Gould <ted@gould.cx> | 2010-02-06 10:34:23 -0800 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-02-06 10:34:23 -0800 |
commit | 5f4f1eb3363b74df3715f8ef9328c5c703f5d6b8 (patch) | |
tree | 0f3fe6bbc77a9019ccd2776a2c2a350a4544ab62 | |
parent | 53bb57465bf4747f56615242d09df562a8a2c3c7 (diff) | |
download | libayatana-appindicator-5f4f1eb3363b74df3715f8ef9328c5c703f5d6b8.tar.gz libayatana-appindicator-5f4f1eb3363b74df3715f8ef9328c5c703f5d6b8.tar.bz2 libayatana-appindicator-5f4f1eb3363b74df3715f8ef9328c5c703f5d6b8.zip |
Putting the proxy construction in an idle function.
-rw-r--r-- | src/libappindicator/app-indicator.c | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index 8d07861..426ee8c 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -690,6 +690,33 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c return; } +/* This is an idle function to create the proxy. This is mostly + because start_fallback_timer can get called in the distruction + of a proxy and thus the proxy manager gets confused when creating + a new proxy as part of destroying an old one. This function being + on idle means that we'll just do it outside of the same stack where + the previous proxy is being destroyed. */ +static gboolean +setup_name_owner_proxy (gpointer data) +{ + g_return_val_if_fail(IS_APP_INDICATOR(data), FALSE); + AppIndicatorPrivate * priv = APP_INDICATOR(data)->priv; + + if (priv->dbus_proxy == NULL) { + priv->dbus_proxy = dbus_g_proxy_new_for_name(priv->connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); + dbus_g_proxy_add_signal(priv->dbus_proxy, "NameOwnerChanged", + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal(priv->dbus_proxy, "NameOwnerChanged", + G_CALLBACK(dbus_owner_change), data, NULL); + } + + return FALSE; +} + /* A function that will start the fallback timer if it's not already started. It sets up the DBus watcher to see if there is a change. Also, provides an override mode for cases @@ -707,15 +734,8 @@ start_fallback_timer (AppIndicator * self, gboolean disable_timeout) } if (priv->dbus_proxy == NULL) { - priv->dbus_proxy = dbus_g_proxy_new_for_name(priv->connection, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - dbus_g_proxy_add_signal(priv->dbus_proxy, "NameOwnerChanged", - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal(priv->dbus_proxy, "NameOwnerChanged", - G_CALLBACK(dbus_owner_change), self, NULL); + /* NOTE: Read the comment on setup_name_owner_proxy */ + g_idle_add(setup_name_owner_proxy, self); } if (disable_timeout) { |