From 8d6afbe9102a979e28c861e3e4d34900cadd2eae Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Fri, 2 Jun 2000 16:12:26 +0000 Subject: Ref and unref objects in the service cache properly. 2000-06-02 Christopher James Lahey * camel-session.c: Ref and unref objects in the service cache properly. * camel-store.c: Ref the folder when returning it using lookup_folder. Used the folder's full name for the key for the folder cache since that's used to uncache it. svn path=/trunk/; revision=3388 --- camel/ChangeLog | 9 +++++++++ camel/camel-session.c | 3 +++ camel/camel-store.c | 10 +++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) (limited to 'camel') diff --git a/camel/ChangeLog b/camel/ChangeLog index f643a09618..64ae632671 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,12 @@ +2000-06-02 Christopher James Lahey + + * camel-session.c: Ref and unref objects in the service cache + properly. + + * camel-store.c: Ref the folder when returning it using + lookup_folder. Used the folder's full name for the key for the + folder cache since that's used to uncache it. + 2000-06-02 Dan Winship Fun with purify. diff --git a/camel/camel-session.c b/camel/camel-session.c index 17d7e60ee0..bc8393b7ef 100644 --- a/camel/camel-session.c +++ b/camel/camel-session.c @@ -26,6 +26,7 @@ */ #include +#include #include "camel-session.h" #include "camel-store.h" #include "camel-transport.h" @@ -191,6 +192,7 @@ camel_session_list_providers (CamelSession *session, gboolean load) static void service_cache_remove(CamelService *service, CamelSession *session) { + gtk_object_unref(GTK_OBJECT(service)); g_hash_table_remove(session->service_cache, service->url); } @@ -247,6 +249,7 @@ camel_session_get_service (CamelSession *session, const char *url_string, service = camel_service_new (provider->object_types[type], session, url, ex); if (service) { g_hash_table_insert(session->service_cache, url, service); + gtk_object_ref(GTK_OBJECT(service)); gtk_signal_connect((GtkObject *)service, "destroy", service_cache_remove, session); } return service; diff --git a/camel/camel-store.c b/camel/camel-store.c index b4eae9975e..ab0c4241f7 100644 --- a/camel/camel-store.c +++ b/camel/camel-store.c @@ -151,8 +151,12 @@ get_default_folder_name (CamelStore *store, CamelException *ex) static CamelFolder * lookup_folder (CamelStore *store, const char *folder_name) { - if (store->folders) - return g_hash_table_lookup (store->folders, folder_name); + if (store->folders) { + CamelFolder *folder = g_hash_table_lookup (store->folders, folder_name); + if (folder) + gtk_object_ref(GTK_OBJECT(folder)); + return folder; + } return NULL; } @@ -166,7 +170,7 @@ cache_folder (CamelStore *store, const char *folder_name, CamelFolder *folder) g_warning ("Caching folder %s that already exists.", folder_name); } - g_hash_table_insert (store->folders, (gpointer)g_strdup(folder_name), folder); + g_hash_table_insert (store->folders, camel_folder_get_full_name (folder), folder); gtk_signal_connect_object (GTK_OBJECT (folder), "destroy", GTK_SIGNAL_FUNC (CS_CLASS (store)->uncache_folder), GTK_OBJECT (store)); -- cgit