From 91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 5 Dec 2012 08:19:04 -0500 Subject: 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. --- em-format/e-mail-formatter-print.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'em-format/e-mail-formatter-print.c') diff --git a/em-format/e-mail-formatter-print.c b/em-format/e-mail-formatter-print.c index 9a57c1f6b5..62e4693cc4 100644 --- a/em-format/e-mail-formatter-print.c +++ b/em-format/e-mail-formatter-print.c @@ -99,7 +99,8 @@ mail_formatter_print_run (EMailFormatter *formatter, CamelStream *stream, GCancellable *cancellable) { - GSList *list, *link; + GQueue queue = G_QUEUE_INIT; + GList *head, *link; GSList *attachments; context->mode = E_MAIL_FORMATTER_MODE_PRINTING; @@ -116,18 +117,18 @@ mail_formatter_print_run (EMailFormatter *formatter, cancellable, NULL); attachments = NULL; - list = context->part_list->list; - for (link = list; link != NULL ; link = g_slist_next (link)) { + e_mail_part_list_queue_parts (context->part_list, NULL, &queue); + + 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); @@ -161,6 +162,9 @@ mail_formatter_print_run (EMailFormatter *formatter, } } + while (!g_queue_is_empty (&queue)) + e_mail_part_unref (g_queue_pop_head (&queue)); + write_attachments_list (formatter, context, attachments, stream, cancellable); g_slist_free (attachments); -- cgit v1.2.3