aboutsummaryrefslogtreecommitdiffstats
path: root/em-format/e-mail-formatter.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 /em-format/e-mail-formatter.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 'em-format/e-mail-formatter.c')
-rw-r--r--em-format/e-mail-formatter.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/em-format/e-mail-formatter.c b/em-format/e-mail-formatter.c
index f878841836..c3a20855a6 100644
--- a/em-format/e-mail-formatter.c
+++ b/em-format/e-mail-formatter.c
@@ -366,26 +366,25 @@ mail_formatter_run (EMailFormatter *formatter,
CamelStream *stream,
GCancellable *cancellable)
{
- GSList *list, *link;
+ GQueue queue = G_QUEUE_INIT;
+ GList *head, *link;
gchar *hdr;
hdr = e_mail_formatter_get_html_header (formatter);
camel_stream_write_string (stream, hdr, cancellable, NULL);
g_free (hdr);
- list = context->part_list->list;
+ e_mail_part_list_queue_parts (context->part_list, NULL, &queue);
- for (link = list; link != NULL; link = g_slist_next (link)) {
+ head = g_queue_peek_head_link (&queue);
+ for (link = head; link != NULL; link = g_list_next (link)) {
EMailPart *part = link->data;
gboolean ok;
if (g_cancellable_is_cancelled (cancellable))
break;
- if (part == NULL)
- continue;
-
if (part->is_hidden && !part->is_error) {
if (g_str_has_suffix (part->id, ".rfc822")) {
link = e_mail_formatter_find_rfc822_end_iter (link);
@@ -446,10 +445,10 @@ mail_formatter_run (EMailFormatter *formatter,
do {
part = link->data;
- if (part && g_str_has_suffix (part->id, ".rfc822.end"))
+ if (g_str_has_suffix (part->id, ".rfc822.end"))
break;
- link = g_slist_next (link);
+ link = g_list_next (link);
} while (link != NULL);
if (link == NULL)
@@ -458,6 +457,9 @@ mail_formatter_run (EMailFormatter *formatter,
}
}
+ while (!g_queue_is_empty (&queue))
+ e_mail_part_unref (g_queue_pop_head (&queue));
+
camel_stream_write_string (stream, "</body></html>", cancellable, NULL);
}