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 /composer | |
parent | 2f0d83cf74b94d5e6272c07179df6e6c7a929789 (diff) | |
download | gsoc2013-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 'composer')
-rw-r--r-- | composer/e-msg-composer.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 76cafab99f..4fa48a717b 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -194,6 +194,7 @@ emcu_part_to_html (CamelSession *session, GString *part_id; EShell *shell; GtkWindow *window; + GSList *list; shell = e_shell_get_default (); window = e_shell_get_active_window (shell); @@ -202,22 +203,31 @@ emcu_part_to_html (CamelSession *session, mem = (CamelStreamMem *) camel_stream_mem_new (); camel_stream_mem_set_byte_array (mem, buf); - part_list = e_mail_part_list_new (); + part_list = e_mail_part_list_new (NULL, NULL, NULL); part_id = g_string_sized_new (0); parser = e_mail_parser_new (session); - part_list->list = e_mail_parser_parse_part (parser, part, part_id, cancellable); + list = e_mail_parser_parse_part (parser, part, part_id, cancellable); + while (list != NULL) { + if (list->data != NULL) { + e_mail_part_list_add_part (part_list, list->data); + e_mail_part_unref (list->data); + } + list = g_slist_delete_link (list, list); + } g_string_free (part_id, TRUE); g_object_unref (parser); - formatter = e_mail_formatter_quote_new (NULL, E_MAIL_FORMATTER_QUOTE_FLAG_KEEP_SIG); - e_mail_formatter_set_style (formatter, - gtk_widget_get_style (GTK_WIDGET (window)), - gtk_widget_get_state (GTK_WIDGET (window))); + formatter = e_mail_formatter_quote_new ( + NULL, E_MAIL_FORMATTER_QUOTE_FLAG_KEEP_SIG); + e_mail_formatter_set_style ( + formatter, + gtk_widget_get_style (GTK_WIDGET (window)), + gtk_widget_get_state (GTK_WIDGET (window))); e_mail_formatter_format_sync ( formatter, part_list, (CamelStream *) mem, - 0, E_MAIL_FORMATTER_MODE_PRINTING, cancellable); + 0, E_MAIL_FORMATTER_MODE_PRINTING, cancellable); g_object_unref (formatter); g_object_unref (part_list); |