From 98e4b44a7d8de667a6531a5a3c4e087ec06010e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erick=20P=C3=A9rez=20Castellanos?= Date: Mon, 8 Dec 2014 11:17:53 -0500 Subject: [PATCH] manager: defer adding client to the internal hash Wait until the client is opened and connected to add it to the internal hash, so GcalManager::get_sources work properly. --- src/gcal-manager.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/gcal-manager.c b/src/gcal-manager.c index 80f53812..423b9475 100644 --- a/src/gcal-manager.c +++ b/src/gcal-manager.c @@ -208,12 +208,6 @@ load_source (GcalManager *manager, if (g_hash_table_lookup (priv->clients, source) == NULL) { - GcalManagerUnit *unit; - - unit = g_new0 (GcalManagerUnit, 1); - - g_hash_table_insert (priv->clients, source, unit); - /* NULL: because maybe the operation cannot be really cancelled */ e_cal_client_connect (source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL, @@ -248,14 +242,15 @@ on_client_connected (GObject *source_object, client = E_CAL_CLIENT (e_cal_client_connect_finish (result, &error)); if (error == NULL) { - unit = (GcalManagerUnit*) g_hash_table_lookup (priv->clients, - source); + unit = g_new0 (GcalManagerUnit, 1); unit->connected = TRUE; unit->client = client; /* FIXME: user should be able to disable sources */ unit->enabled = TRUE; + g_hash_table_insert (priv->clients, source, unit); + g_debug ("Source %s (%s) connected", e_source_get_display_name (source), e_source_get_uid (source));