From 09d4af6fff63dd112b8bb42087f14f7018e2f78c Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 2 Oct 2007 11:54:42 +0000 Subject: ** Fixes bug #469657 2007-10-02 Matthew Barnes ** Fixes bug #469657 * addressbook/importers/evolution-ldif-importer.c: * calendar/gui/comp-editor-factory.c: * composer/e-msg-composer.c: * e-util/e-config-listener.c: * mail/em-composer-prefs.c: * mail/em-folder-tree-model.c: * mail/em-format.c: * mail/em-format-html.c: * mail/em-migrate.c: * mail/em-subscribe-editor.c: * mail/mail-component.c: * mail/mail-send-recv.c: * mail/message-list.c: * mail/importers/elm-importer.c: * plugins/exchange-operations/exchange-folder-size-display.c: * plugins/mono/mono-plugin.c: * shell/e-shell-settings-dialog.c: * tools/killev.c: * widgets/table/e-table-extras.c: * widgets/table/e-table-selection-model.c: Use destroy functions in GHashTables to simplify memory management. svn path=/trunk/; revision=34344 --- mail/mail-component.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'mail/mail-component.c') diff --git a/mail/mail-component.c b/mail/mail-component.c index c27fee6250..2aa9274b30 100644 --- a/mail/mail-component.c +++ b/mail/mail-component.c @@ -459,13 +459,6 @@ impl_dispose (GObject *object) (* G_OBJECT_CLASS (parent_class)->dispose) (object); } -static void -store_hash_free (CamelStore *store, struct _store_info *si, void *data) -{ - si->removed = 1; - store_info_unref(si); -} - static void impl_finalize (GObject *object) { @@ -475,7 +468,6 @@ impl_finalize (GObject *object) mail_async_event_destroy (priv->async_event); - g_hash_table_foreach (priv->store_hash, (GHFunc)store_hash_free, NULL); g_hash_table_destroy (priv->store_hash); if (mail_async_event_destroy (priv->async_event) == -1) { @@ -1171,6 +1163,13 @@ mail_component_class_init (MailComponentClass *class) mepv->test = impl_mail_test; } +static void +store_hash_free (struct _store_info *si) +{ + si->removed = 1; + store_info_unref(si); +} + static void mail_component_init (MailComponent *component) { @@ -1200,7 +1199,10 @@ mail_component_init (MailComponent *component) mail_session_init (priv->base_directory); priv->async_event = mail_async_event_new(); - priv->store_hash = g_hash_table_new (NULL, NULL); + priv->store_hash = g_hash_table_new_full ( + NULL, NULL, + (GDestroyNotify) NULL, + (GDestroyNotify) store_hash_free); mail_autoreceive_init(); } @@ -1319,7 +1321,6 @@ void mail_component_remove_store (MailComponent *component, CamelStore *store) { MailComponentPrivate *priv; - struct _store_info *si; MAIL_COMPONENT_DEFAULT(component); @@ -1331,13 +1332,11 @@ mail_component_remove_store (MailComponent *component, CamelStore *store) * URL will always return the same object. So this works. */ - if (!(si = g_hash_table_lookup (priv->store_hash, store))) + if (g_hash_table_lookup (priv->store_hash, store) == NULL) return; camel_object_ref (store); g_hash_table_remove (priv->store_hash, store); - si->removed = 1; - store_info_unref(si); /* so i guess potentially we could have a race, add a store while one being removed. ?? */ -- cgit v1.2.3