aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-01-09 17:06:45 -0600
committerTed Gould <ted@gould.cx>2011-01-09 17:06:45 -0600
commit4a3d68bb35a2f371708568e199bdb0fc92af4ef5 (patch)
treeceb6c4999e33eb57cc16c1630c90cf50ad233dbd
parent664e39bbed088df649d3135a0fd1c09f1fd882b6 (diff)
downloadlibayatana-indicator-4a3d68bb35a2f371708568e199bdb0fc92af4ef5.tar.gz
libayatana-indicator-4a3d68bb35a2f371708568e199bdb0fc92af4ef5.tar.bz2
libayatana-indicator-4a3d68bb35a2f371708568e199bdb0fc92af4ef5.zip
Using the GCancellable to detect if we're already creating a proxy so that we don't do it twice.
-rw-r--r--libindicator/indicator-service-manager.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c
index 4f98a5c..34b6baa 100644
--- a/libindicator/indicator-service-manager.c
+++ b/libindicator/indicator-service-manager.c
@@ -417,14 +417,17 @@ start_service (IndicatorServiceManager * service)
g_return_if_fail(priv->name != NULL);
+ if (priv->service_proxy_cancel != NULL) {
+ /* A service proxy is being gotten currently */
+ return;
+ }
+
if (priv->service_proxy != NULL) {
g_object_unref(priv->service_proxy);
priv->service_proxy = NULL;
}
- if (priv->service_proxy_cancel == NULL) {
- priv->service_proxy_cancel = g_cancellable_new();
- }
+ priv->service_proxy_cancel = g_cancellable_new();
g_dbus_proxy_new_for_bus(G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
@@ -446,13 +449,24 @@ static void
service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data)
{
GError * error = NULL;
+
+ IndicatorServiceManager * service = INDICATOR_SERVICE_MANAGER(user_data);
+ g_return_if_fail(service != NULL);
+
GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error);
+ IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(user_data);
+
+ if (priv->service_proxy_cancel != NULL) {
+ g_object_unref(priv->service_proxy_cancel);
+ priv->service_proxy_cancel = NULL;
+ }
+
if (error != NULL) {
/* Unable to create the proxy, eh, let's try again
in a bit */
g_error_free(error);
- start_service_again(INDICATOR_SERVICE_MANAGER(user_data));
+ start_service_again(service);
return;
}
@@ -462,12 +476,13 @@ service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data)
odd that it wouldn't have an owner at this point. But, all
we can do is try again. */
g_object_unref(proxy);
- start_service_again(INDICATOR_SERVICE_MANAGER(user_data));
+ start_service_again(service);
return;
}
g_free(name);
- IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(user_data);
+ /* Okay, we're good to grab the proxy at this point, we're
+ sure that it's ours. */
priv->service_proxy = proxy;
/* Signal for drop */