[gnome-calendar] manager: defer adding client to the internal hash



commit 98e4b44a7d8de667a6531a5a3c4e087ec06010e2
Author: Erick Pérez Castellanos <erick red gmail com>
Date:   Mon Dec 8 11:17:53 2014 -0500

    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 files changed, 3 insertions(+), 8 deletions(-)
---
diff --git a/src/gcal-manager.c b/src/gcal-manager.c
index 80f5381..423b947 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));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]