[evolution-data-server/gnome-3-4] Make sure loaded info is also freed before using camel_folder_summary_remove_uid()
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-4] Make sure loaded info is also freed before using camel_folder_summary_remove_uid()
- Date: Thu, 19 Jul 2012 20:34:20 +0000 (UTC)
commit b5c292e139e2403c3149ea6837a480b18ca3f9fb
Author: Milan Crha <mcrha redhat com>
Date: Thu Jul 19 22:33:46 2012 +0200
Make sure loaded info is also freed before using camel_folder_summary_remove_uid()
The problem is that camel_folder_summary_remove_uid() doesn't free loaded
CamelMessageInfo, if there is any, it does only camel_folder_summary_remove(),
thus this might be done on each place, unfortunately.
camel/camel-vee-folder.c | 48 ++++++++++++++++---------
camel/providers/imap/camel-imap-folder.c | 31 +++++++++++++++--
camel/providers/local/camel-maildir-folder.c | 3 +-
camel/providers/local/camel-mbox-folder.c | 2 +-
camel/providers/local/camel-mbox-summary.c | 5 ++-
camel/providers/local/camel-mh-folder.c | 3 +-
camel/providers/nntp/camel-nntp-folder.c | 9 ++++-
camel/providers/nntp/camel-nntp-summary.c | 11 +++++-
8 files changed, 83 insertions(+), 29 deletions(-)
---
diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c
index ba674cb..a23cf50 100644
--- a/camel/camel-vee-folder.c
+++ b/camel/camel-vee-folder.c
@@ -183,8 +183,8 @@ folder_changed_add_uid (CamelFolder *sub,
*unm_added_l = g_list_prepend (*unm_added_l, (gpointer) camel_pstring_strdup (vuid));
- camel_folder_summary_remove_uid (
- CAMEL_FOLDER (folder_unmatched)->summary, vuid);
+ camel_folder_summary_remove (
+ CAMEL_FOLDER (folder_unmatched)->summary, (CamelMessageInfo *) vinfo);
camel_folder_free_message_info (
CAMEL_FOLDER (folder_unmatched),
(CamelMessageInfo *) vinfo);
@@ -220,7 +220,13 @@ folder_changed_remove_uid (CamelFolder *sub,
if (use_db)
*m_removed_l = g_list_prepend (*m_removed_l, (gpointer) camel_pstring_strdup (vuid));
- camel_folder_summary_remove_uid (folder->summary, vuid);
+ vinfo = (CamelVeeMessageInfo *) camel_folder_summary_peek_loaded (folder->summary, vuid);
+ if (vinfo) {
+ camel_folder_summary_remove (folder->summary, (CamelMessageInfo *) vinfo);
+ camel_message_info_free ((CamelMessageInfo *) vinfo);
+ } else {
+ camel_folder_summary_remove_uid (folder->summary, vuid);
+ }
if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0 && !CAMEL_IS_VEE_FOLDER (sub) && folder_unmatched != NULL) {
if (keep) {
@@ -251,8 +257,8 @@ folder_changed_remove_uid (CamelFolder *sub,
*unm_removed_l = g_list_prepend (*unm_removed_l, (gpointer) camel_pstring_strdup (vuid));
- camel_folder_summary_remove_uid (
- CAMEL_FOLDER (folder_unmatched)->summary, vuid);
+ camel_folder_summary_remove (
+ CAMEL_FOLDER (folder_unmatched)->summary, (CamelMessageInfo *) vinfo);
camel_folder_free_message_info (
CAMEL_FOLDER (folder_unmatched),
(CamelMessageInfo *) vinfo);
@@ -751,16 +757,16 @@ unmatched_check_uid (gchar *uidin,
if (vee_folder_add_uid_test (u->folder_unmatched, u->source, uidin, u->hash))
camel_folder_change_info_add_uid (u->folder_unmatched->changes, uid);
} else {
- CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *) camel_folder_summary_get (((CamelFolder *) u->folder_unmatched)->summary, uid);
+ CamelMessageInfo *mi = camel_folder_summary_get (((CamelFolder *) u->folder_unmatched)->summary, uid);
if (mi) {
if (u->message_uids != NULL)
g_queue_push_tail (u->message_uids, g_strdup (uid));
- camel_folder_summary_remove_uid (
- ((CamelFolder *) u->folder_unmatched)->summary, uid);
+ camel_folder_summary_remove (
+ ((CamelFolder *) u->folder_unmatched)->summary, mi);
camel_folder_change_info_remove_uid (
u->folder_unmatched->changes, uid);
- camel_message_info_free ((CamelMessageInfo *) mi);
+ camel_message_info_free (mi);
}
}
}
@@ -1449,12 +1455,14 @@ vee_folder_synchronize_sync (CamelFolder *folder,
known_uids = camel_folder_summary_get_array (folder->summary);
for (i = 0; known_uids && i < known_uids->len; i++) {
CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *) camel_folder_summary_get (folder->summary, g_ptr_array_index (known_uids, i));
- if (mi->old_flags & CAMEL_MESSAGE_DELETED) {
- del = g_list_prepend (del, (gpointer) camel_pstring_strdup (((CamelMessageInfo *) mi)->uid));
- camel_folder_summary_remove_uid (folder->summary, ((CamelMessageInfo *) mi)->uid);
+ if (mi) {
+ if (mi->old_flags & CAMEL_MESSAGE_DELETED) {
+ del = g_list_prepend (del, (gpointer) camel_pstring_strdup (((CamelMessageInfo *) mi)->uid));
+ camel_folder_summary_remove (folder->summary, (CamelMessageInfo *) mi);
+ }
+ camel_message_info_free (mi);
}
- camel_message_info_free (mi);
}
camel_folder_summary_free_array (known_uids);
@@ -1592,7 +1600,7 @@ vee_folder_remove_folder_helper (CamelVeeFolder *vf,
if (mi) {
if (mi->orig_summary == ssummary) {
camel_folder_change_info_remove_uid (folder_unmatched->changes, camel_message_info_uid (mi));
- camel_folder_summary_remove_uid (((CamelFolder *) folder_unmatched)->summary, camel_message_info_uid (mi));
+ camel_folder_summary_remove (((CamelFolder *) folder_unmatched)->summary, (CamelMessageInfo *) mi);
}
camel_message_info_free ((CamelMessageInfo *) mi);
}
@@ -1611,7 +1619,7 @@ vee_folder_remove_folder_helper (CamelVeeFolder *vf,
const gchar *uid = camel_message_info_uid (mi);
camel_folder_change_info_remove_uid (vf->changes, uid);
- camel_folder_summary_remove_uid (folder->summary, uid);
+ camel_folder_summary_remove (folder->summary, (CamelMessageInfo *) mi);
if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0 && folder_unmatched != NULL) {
if (still) {
@@ -1803,7 +1811,7 @@ vee_folder_rebuild_folder (CamelVeeFolder *vee_folder,
if (g_hash_table_lookup (matchhash, uid + 8) == NULL) {
camel_folder_change_info_remove_uid (vee_folder->changes, camel_message_info_uid (mi));
- camel_folder_summary_remove_uid (folder->summary, uid);
+ camel_folder_summary_remove (folder->summary, (CamelMessageInfo *) mi);
if (!CAMEL_IS_VEE_FOLDER (source)
&& unmatched_uids != NULL
@@ -1868,7 +1876,13 @@ vee_folder_rebuild_folder (CamelVeeFolder *vee_folder,
if (strncmp (uid, u.hash, 8) == 0) {
if (g_hash_table_lookup (allhash, uid + 8) == NULL) {
/* no longer exists at all, just remove it entirely */
- camel_folder_summary_remove_uid (((CamelFolder *) folder_unmatched)->summary, uid);
+ CamelMessageInfo *mi = camel_folder_summary_peek_loaded (((CamelFolder *) folder_unmatched)->summary, uid);
+ if (mi) {
+ camel_folder_summary_remove (((CamelFolder *) folder_unmatched)->summary, mi);
+ camel_message_info_free (mi);
+ } else {
+ camel_folder_summary_remove_uid (((CamelFolder *) folder_unmatched)->summary, uid);
+ }
camel_folder_change_info_remove_uid (folder_unmatched->changes, uid);
} else {
g_hash_table_remove (allhash, uid + 8);
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index a0aeda1..e771152 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -1912,7 +1912,15 @@ imap_expunge_uids_offline (CamelFolder *folder,
changes = camel_folder_change_info_new ();
for (i = 0; i < uids->len; i++) {
- camel_folder_summary_remove_uid (folder->summary, uids->pdata[i]);
+ CamelMessageInfo *mi = camel_folder_summary_peek_loaded (folder->summary, uids->pdata[i]);
+
+ if (mi) {
+ camel_folder_summary_remove (folder->summary, mi);
+ camel_message_info_free (mi);
+ } else {
+ camel_folder_summary_remove_uid (folder->summary, uids->pdata[i]);
+ }
+
camel_folder_change_info_remove_uid (changes, uids->pdata[i]);
list = g_list_prepend (list, (gpointer) uids->pdata[i]);
/* We intentionally don't remove it from the cache because
@@ -2015,7 +2023,15 @@ imap_expunge_uids_online (CamelFolder *folder,
changes = camel_folder_change_info_new ();
for (i = 0; i < uids->len; i++) {
- camel_folder_summary_remove_uid (folder->summary, uids->pdata[i]);
+ CamelMessageInfo *mi = camel_folder_summary_peek_loaded (folder->summary, uids->pdata[i]);
+
+ if (mi) {
+ camel_folder_summary_remove (folder->summary, mi);
+ camel_message_info_free (mi);
+ } else {
+ camel_folder_summary_remove_uid (folder->summary, uids->pdata[i]);
+ }
+
camel_folder_change_info_remove_uid (changes, uids->pdata[i]);
list = g_list_prepend (list, (gpointer) uids->pdata[i]);
/* We intentionally don't remove it from the cache because
@@ -4370,6 +4386,8 @@ camel_imap_folder_changed (CamelFolder *folder,
known_uids = camel_folder_summary_get_array (folder->summary);
camel_folder_sort_uids (folder, known_uids);
for (i = 0; i < expunged->len; i++) {
+ CamelMessageInfo *mi;
+
id = g_array_index (expunged, int, i);
uid = id - 1 + i >= 0 && id - 1 + i < known_uids->len ? g_ptr_array_index (known_uids, id - 1 + i) : NULL;
if (uid == NULL) {
@@ -4383,7 +4401,14 @@ camel_imap_folder_changed (CamelFolder *folder,
CAMEL_IMAP_FOLDER_REC_LOCK (imap_folder, cache_lock);
camel_imap_message_cache_remove (imap_folder->cache, uid);
CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
- camel_folder_summary_remove_uid (folder->summary, uid);
+
+ mi = camel_folder_summary_peek_loaded (folder->summary, uid);
+ if (mi) {
+ camel_folder_summary_remove (folder->summary, mi);
+ camel_message_info_free (mi);
+ } else {
+ camel_folder_summary_remove_uid (folder->summary, uid);
+ }
}
/* Delete all in one transaction */
diff --git a/camel/providers/local/camel-maildir-folder.c b/camel/providers/local/camel-maildir-folder.c
index f8aadd7..22a7b6e 100644
--- a/camel/providers/local/camel-maildir-folder.c
+++ b/camel/providers/local/camel-maildir-folder.c
@@ -219,8 +219,7 @@ maildir_folder_append_message_sync (CamelFolder *folder,
fail_write:
/* remove the summary info so we are not out-of-sync with the mh folder */
- camel_folder_summary_remove_uid (CAMEL_FOLDER_SUMMARY (folder->summary),
- camel_message_info_uid (mi));
+ camel_folder_summary_remove (CAMEL_FOLDER_SUMMARY (folder->summary), mi);
g_prefix_error (
error, _("Cannot append message to maildir folder: %s: "),
diff --git a/camel/providers/local/camel-mbox-folder.c b/camel/providers/local/camel-mbox-folder.c
index 85424bf..29dcef4 100644
--- a/camel/providers/local/camel-mbox-folder.c
+++ b/camel/providers/local/camel-mbox-folder.c
@@ -272,7 +272,7 @@ fail_write:
g_free (fromline);
/* remove the summary info so we are not out-of-sync with the mbox */
- camel_folder_summary_remove_uid (CAMEL_FOLDER_SUMMARY (mbs), camel_message_info_uid (mi));
+ camel_folder_summary_remove (CAMEL_FOLDER_SUMMARY (mbs), mi);
/* and tell the summary it's up-to-date */
if (g_stat (lf->folder_path, &st) == 0) {
diff --git a/camel/providers/local/camel-mbox-summary.c b/camel/providers/local/camel-mbox-summary.c
index 2d2065f..6821715 100644
--- a/camel/providers/local/camel-mbox-summary.c
+++ b/camel/providers/local/camel-mbox-summary.c
@@ -514,7 +514,8 @@ summary_update (CamelLocalSummary *cls,
if (changeinfo)
camel_folder_change_info_remove_uid (changeinfo, uid);
del = g_list_prepend (del, (gpointer) camel_pstring_strdup (uid));
- camel_folder_summary_remove_uid (s, uid);
+ if (mi)
+ camel_folder_summary_remove (s, (CamelMessageInfo *) mi);
}
if (mi)
@@ -1135,7 +1136,7 @@ camel_mbox_summary_sync_mbox (CamelMboxSummary *cls,
/* remove it from the change list */
camel_folder_change_info_remove_uid (changeinfo, uid);
- camel_folder_summary_remove_uid (s, uid);
+ camel_folder_summary_remove (s, (CamelMessageInfo *) info);
del = g_list_prepend (del, (gpointer) camel_pstring_strdup (uid));
camel_message_info_free ((CamelMessageInfo *) info);
info = NULL;
diff --git a/camel/providers/local/camel-mh-folder.c b/camel/providers/local/camel-mh-folder.c
index c9caf21..e2ec447 100644
--- a/camel/providers/local/camel-mh-folder.c
+++ b/camel/providers/local/camel-mh-folder.c
@@ -112,8 +112,7 @@ mh_folder_append_message_sync (CamelFolder *folder,
fail_write:
/* remove the summary info so we are not out-of-sync with the mh folder */
- camel_folder_summary_remove_uid (CAMEL_FOLDER_SUMMARY (folder->summary),
- camel_message_info_uid (mi));
+ camel_folder_summary_remove (CAMEL_FOLDER_SUMMARY (folder->summary), mi);
g_prefix_error (
error, _("Cannot append message to mh folder: %s: "), name);
diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c
index b557ebc..0d2ec02 100644
--- a/camel/providers/nntp/camel-nntp-folder.c
+++ b/camel/providers/nntp/camel-nntp-folder.c
@@ -701,7 +701,14 @@ nntp_folder_expunge_uids_offline (CamelFolder *folder,
changes = camel_folder_change_info_new ();
for (ii = 0; ii < uids->len; ii++) {
- camel_folder_summary_remove_uid (folder->summary, uids->pdata[ii]);
+ CamelMessageInfo *mi = camel_folder_summary_peek_loaded (folder->summary, uids->pdata[ii]);
+ if (mi) {
+ camel_folder_summary_remove (folder->summary, mi);
+ camel_message_info_free (mi);
+ } else {
+ camel_folder_summary_remove_uid (folder->summary, uids->pdata[ii]);
+ }
+
camel_folder_change_info_remove_uid (changes, uids->pdata[ii]);
}
diff --git a/camel/providers/nntp/camel-nntp-summary.c b/camel/providers/nntp/camel-nntp-summary.c
index 329c0d2..fa7c9ad 100644
--- a/camel/providers/nntp/camel-nntp-summary.c
+++ b/camel/providers/nntp/camel-nntp-summary.c
@@ -462,6 +462,8 @@ camel_nntp_summary_check (CamelNNTPSummary *cns,
n = strtoul (uid, NULL, 10);
if (n < f || n > l) {
+ CamelMessageInfo *mi;
+
dd (printf ("nntp_summary: %u is lower/higher than lowest/highest article, removed\n", n));
/* Since we use a global cache this could prematurely remove
* a cached message that might be in another folder - not that important as
@@ -471,7 +473,14 @@ camel_nntp_summary_check (CamelNNTPSummary *cns,
camel_data_cache_remove (store->cache, "cache", msgid + 1, NULL);
camel_folder_change_info_remove_uid (changes, uid);
del = g_list_prepend (del, (gpointer) camel_pstring_strdup (uid));
- camel_folder_summary_remove_uid (s, uid);
+
+ mi = camel_folder_summary_peek_loaded (s, uid);
+ if (mi) {
+ camel_folder_summary_remove (s, mi);
+ camel_message_info_free (mi);
+ } else {
+ camel_folder_summary_remove_uid (s, uid);
+ }
}
}
camel_folder_summary_free_array (known_uids);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]