aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-utils.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-12-05 21:19:04 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-12-08 03:01:04 +0800
commit91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8 (patch)
tree1c06f36fa153eee0779cdfa1be1a24f62e93787d /mail/em-utils.c
parent2f0d83cf74b94d5e6272c07179df6e6c7a929789 (diff)
downloadgsoc2013-evolution-91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8.tar
gsoc2013-evolution-91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8.tar.gz
gsoc2013-evolution-91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8.tar.bz2
gsoc2013-evolution-91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8.tar.lz
gsoc2013-evolution-91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8.tar.xz
gsoc2013-evolution-91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8.tar.zst
gsoc2013-evolution-91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8.zip
Make EMailPartList thread-safe.
Exposing data members in the public struct is unwise, especially when EMailPartList is used from multiple threads. Instead keep the members private and provide a set of thread-safe functions to manipulate them.
Diffstat (limited to 'mail/em-utils.c')
-rw-r--r--mail/em-utils.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 923b11f9c4..d533be741d 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -1229,12 +1229,12 @@ em_utils_get_proxy (void)
}
static gboolean
-is_only_text_part_in_this_level (GSList *parts,
+is_only_text_part_in_this_level (GList *parts,
EMailPart *text_html_part)
{
const gchar *dot;
gint level_len;
- GSList *iter;
+ GList *iter;
g_return_val_if_fail (parts != NULL, FALSE);
g_return_val_if_fail (text_html_part != NULL, FALSE);
@@ -1297,7 +1297,8 @@ em_utils_message_to_html (CamelSession *session,
GtkWindow *window;
EMailPart *hidden_text_html_part = NULL;
guint32 is_validity_found = 0;
- GSList *iter;
+ GQueue queue = G_QUEUE_INIT;
+ GList *head, *link;
shell = e_shell_get_default ();
window = e_shell_get_active_window (shell);
@@ -1333,18 +1334,18 @@ em_utils_message_to_html (CamelSession *session,
}
/* Return all found validities and possibly show hidden prefer-plain part */
- for (iter = parts_list->list; iter; iter = iter->next) {
+ e_mail_part_list_queue_parts (parts_list, NULL, &queue);
+ head = g_queue_peek_head_link (&queue);
- EMailPart *part = iter->data;
- if (!part)
- continue;
+ for (link = head; link != NULL; link = g_list_next (link)) {
+ EMailPart *part = link->data;
/* prefer-plain can hide HTML parts, even when it's the only
* text part in the email, thus show it (and hide again later) */
if (part->is_hidden && !hidden_text_html_part &&
part->mime_type && !part->is_attachment &&
g_ascii_strcasecmp (part->mime_type, "text/html") == 0 &&
- is_only_text_part_in_this_level (parts_list->list, part)) {
+ is_only_text_part_in_this_level (head, part)) {
part->is_hidden = FALSE;
hidden_text_html_part = part;
}
@@ -1361,6 +1362,9 @@ em_utils_message_to_html (CamelSession *session,
}
}
+ while (!g_queue_is_empty (&queue))
+ e_mail_part_unref (g_queue_pop_head (&queue));
+
if (validity_found)
*validity_found = is_validity_found;