diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-02-18 03:22:39 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-02-18 03:29:49 +0800 |
commit | d84b67875c88bc600e55f5e3060820530e46cc56 (patch) | |
tree | c7a18be93d1b9a2bbf55122d8482dd37f81a7875 /e-util | |
parent | 7c06909d5ea781449a177fdc320a3a2de2901fa9 (diff) | |
download | gsoc2013-evolution-d84b67875c88bc600e55f5e3060820530e46cc56.tar gsoc2013-evolution-d84b67875c88bc600e55f5e3060820530e46cc56.tar.gz gsoc2013-evolution-d84b67875c88bc600e55f5e3060820530e46cc56.tar.bz2 gsoc2013-evolution-d84b67875c88bc600e55f5e3060820530e46cc56.tar.lz gsoc2013-evolution-d84b67875c88bc600e55f5e3060820530e46cc56.tar.xz gsoc2013-evolution-d84b67875c88bc600e55f5e3060820530e46cc56.tar.zst gsoc2013-evolution-d84b67875c88bc600e55f5e3060820530e46cc56.zip |
EClientCache: Keep a strong reference on the ESourceRegistry.
Changed my mind. There's some scenarios where a function depends on an
ESourceRegistry but could also utilize an EClientCache, and it would be
nice to just pass the EClientCache and extract the ESourceRegistry from
it, so we need to make sure the ESourceRegistry will be there when it's
needed and not quietly disappear.
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/e-client-cache.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/e-util/e-client-cache.c b/e-util/e-client-cache.c index d99302a1b5..b9bbb54e76 100644 --- a/e-util/e-client-cache.c +++ b/e-util/e-client-cache.c @@ -47,7 +47,7 @@ typedef struct _ClientData ClientData; typedef struct _SignalClosure SignalClosure; struct _EClientCachePrivate { - GWeakRef registry; + ESourceRegistry *registry; GHashTable *client_ht; GMutex client_ht_lock; @@ -215,37 +215,35 @@ static gchar * client_cache_build_source_description (EClientCache *cache, ESource *source) { - GString *description; ESourceRegistry *registry; + ESource *parent; + GString *description; gchar *display_name; + gchar *parent_uid; description = g_string_sized_new (128); registry = e_client_cache_ref_registry (cache); - if (registry != NULL) { - ESource *parent; - gchar *parent_uid; - parent_uid = e_source_dup_parent (source); - parent = e_source_registry_ref_source (registry, parent_uid); - g_free (parent_uid); + parent_uid = e_source_dup_parent (source); + parent = e_source_registry_ref_source (registry, parent_uid); + g_free (parent_uid); - if (parent != NULL) { - display_name = e_source_dup_display_name (parent); - g_string_append (description, display_name); - g_string_append (description, " / "); - g_free (display_name); + if (parent != NULL) { + display_name = e_source_dup_display_name (parent); + g_string_append (description, display_name); + g_string_append (description, " / "); + g_free (display_name); - g_object_unref (parent); - } - - g_object_unref (registry); + g_object_unref (parent); } display_name = e_source_dup_display_name (source); g_string_append (description, display_name); g_free (display_name); + g_object_unref (registry); + return g_string_free (description, FALSE); } @@ -524,8 +522,9 @@ client_cache_set_registry (EClientCache *cache, ESourceRegistry *registry) { g_return_if_fail (E_IS_SOURCE_REGISTRY (registry)); + g_return_if_fail (cache->priv->registry == NULL); - g_weak_ref_set (&cache->priv->registry, registry); + cache->priv->registry = g_object_ref (registry); } static void @@ -570,7 +569,7 @@ client_cache_dispose (GObject *object) priv = E_CLIENT_CACHE_GET_PRIVATE (object); - g_weak_ref_set (&priv->registry, NULL); + g_clear_object (&priv->registry); g_hash_table_remove_all (priv->client_ht); @@ -783,7 +782,7 @@ e_client_cache_ref_registry (EClientCache *cache) { g_return_val_if_fail (E_IS_CLIENT_CACHE (cache), NULL); - return g_weak_ref_get (&cache->priv->registry); + return g_object_ref (cache->priv->registry); } /** |