diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2012-12-05 21:19:04 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2012-12-08 03:01:04 +0800 |
commit | 91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8 (patch) | |
tree | 1c06f36fa153eee0779cdfa1be1a24f62e93787d /em-format/e-mail-formatter-quote.c | |
parent | 2f0d83cf74b94d5e6272c07179df6e6c7a929789 (diff) | |
download | gsoc2013-evolution-91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8.tar.gz 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-quote.c')
-rw-r--r-- | em-format/e-mail-formatter-quote.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/em-format/e-mail-formatter-quote.c b/em-format/e-mail-formatter-quote.c index fcd2a06b48..3cd0121b72 100644 --- a/em-format/e-mail-formatter-quote.c +++ b/em-format/e-mail-formatter-quote.c @@ -50,7 +50,8 @@ mail_formatter_quote_run (EMailFormatter *formatter, EMailFormatterQuote *qf; EMailFormatterQuoteContext *qf_context; GSettings *settings; - GSList *list, *link; + GQueue queue = G_QUEUE_INIT; + GList *head, *link; if (g_cancellable_is_cancelled (cancellable)) return; @@ -87,13 +88,12 @@ mail_formatter_quote_run (EMailFormatter *formatter, "<blockquote type=cite>\n", cancellable, NULL); } - 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)) { - EMailPart *part = link->data; + head = g_queue_peek_head_link (&queue); - if (!part) - continue; + for (link = head; link != NULL; link = g_list_next (link)) { + EMailPart *part = link->data; if (g_str_has_suffix (part->id, ".headers") && !(qf_context->qf_flags & E_MAIL_FORMATTER_QUOTE_FLAG_HEADERS)) { @@ -105,17 +105,11 @@ mail_formatter_quote_run (EMailFormatter *formatter, while (link != NULL) { EMailPart *p = link->data; - if (p == NULL) { - link = g_slist_next (link); - if (link == NULL) - break; - continue; - } if (g_strcmp0 (p->id, end) == 0) break; - link = g_slist_next (link); + link = g_list_next (link); if (link == NULL) break; } @@ -132,6 +126,9 @@ mail_formatter_quote_run (EMailFormatter *formatter, part->mime_type, cancellable); } + while (!g_queue_is_empty (&queue)) + e_mail_part_unref (g_queue_pop_head (&queue)); + if (qf->priv->flags & E_MAIL_FORMATTER_QUOTE_FLAG_CITE) { camel_stream_write_string ( stream, "</blockquote><!--+GtkHTML:" |