From 4299e16b3356da0a752d5ae5ccaf1c981c467e5d Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 15 Feb 2010 17:05:26 +0100 Subject: [PATCH] Bug #574940 - Always ref returned info from message_info_from_uid --- camel/camel-folder-summary.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c index 96574a7..49586e0 100644 --- a/camel/camel-folder-summary.c +++ b/camel/camel-folder-summary.c @@ -541,7 +541,6 @@ message_info_from_uid (CamelFolderSummary *s, const gchar *uid) gint ret; CAMEL_SUMMARY_LOCK(s, summary_lock); - CAMEL_SUMMARY_LOCK(s, ref_lock); info = g_hash_table_lookup (s->loaded_infos, uid); @@ -558,7 +557,6 @@ message_info_from_uid (CamelFolderSummary *s, const gchar *uid) folder_name = s->folder->full_name; cdb = s->folder->parent_store->cdb_r; - CAMEL_SUMMARY_UNLOCK(s, ref_lock); CAMEL_SUMMARY_UNLOCK(s, summary_lock); data.summary = s; @@ -572,7 +570,6 @@ message_info_from_uid (CamelFolderSummary *s, const gchar *uid) } CAMEL_SUMMARY_LOCK(s, summary_lock); - CAMEL_SUMMARY_LOCK(s, ref_lock); /* We would have double reffed at camel_read_mir_callback */ info = g_hash_table_lookup (s->loaded_infos, uid); @@ -586,10 +583,11 @@ message_info_from_uid (CamelFolderSummary *s, const gchar *uid) camel_exception_clear (&ex); g_free (errmsg); } - } else - info->refcount++; + } + + if (info) + camel_message_info_ref (info); - CAMEL_SUMMARY_UNLOCK(s, ref_lock); CAMEL_SUMMARY_UNLOCK(s, summary_lock); return info; @@ -2348,11 +2346,12 @@ summary_remove_uid (CamelFolderSummary *s, const gchar *uid) void camel_folder_summary_remove (CamelFolderSummary *s, CamelMessageInfo *info) { - + gboolean found; gint ret; CAMEL_SUMMARY_LOCK(s, summary_lock); + found = g_hash_table_lookup (s->loaded_infos, camel_message_info_uid (info)) != NULL; g_hash_table_remove (s->loaded_infos, camel_message_info_uid(info)); ret = summary_remove_uid (s, camel_message_info_uid(info)); @@ -2363,7 +2362,8 @@ camel_folder_summary_remove (CamelFolderSummary *s, CamelMessageInfo *info) if (!ret && camel_db_delete_uid (s->folder->parent_store->cdb_w, s->folder->full_name, camel_message_info_uid(info), NULL) != 0) return; - camel_message_info_free(info); + if (found) + camel_message_info_free (info); } /** @@ -3497,7 +3497,7 @@ message_info_free(CamelFolderSummary *s, CamelMessageInfo *info) CamelMessageInfoBase *mi = (CamelMessageInfoBase *)info; if (mi->uid) { - if (g_hash_table_lookup (s->loaded_infos, mi->uid) == mi) { + if (s && g_hash_table_lookup (s->loaded_infos, mi->uid) == mi) { g_hash_table_remove (s->loaded_infos, mi->uid); } camel_pstring_free(mi->uid); -- 2.7.4