aboutsummaryrefslogtreecommitdiffstats
path: root/em-format
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-05-23 00:11:59 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-05-24 04:36:02 +0800
commit9058c6f85dc49f9500e7e67819acfd8c0d2d369c (patch)
tree5802baf603e0995132e3652a6681068f0d9f060a /em-format
parent256422cab27d0b7adbe99fdeaceb72cd78c129bb (diff)
downloadgsoc2013-evolution-9058c6f85dc49f9500e7e67819acfd8c0d2d369c.tar
gsoc2013-evolution-9058c6f85dc49f9500e7e67819acfd8c0d2d369c.tar.gz
gsoc2013-evolution-9058c6f85dc49f9500e7e67819acfd8c0d2d369c.tar.bz2
gsoc2013-evolution-9058c6f85dc49f9500e7e67819acfd8c0d2d369c.tar.lz
gsoc2013-evolution-9058c6f85dc49f9500e7e67819acfd8c0d2d369c.tar.xz
gsoc2013-evolution-9058c6f85dc49f9500e7e67819acfd8c0d2d369c.tar.zst
gsoc2013-evolution-9058c6f85dc49f9500e7e67819acfd8c0d2d369c.zip
Make EAttachment a little more thread-safe.
EAttachment is now used from worker threads by EMailFormatterAttachment, so add some thread-safe accessor functions to eliminate potential races. Added thread-safe functions: e_attachment_dup_disposition() e_attachment_ref_file() e_attachment_ref_file_info() e_attachment_ref_icon() e_attachment_ref_mime_part() e_attachment_dup_description() e_attachment_dup_thumbnail_path() Renamed functions: e_attachment_get_mime_type() -> e_attachment_dup_mime_type() Removed non-thread-safe functions: e_attachment_get_file() e_attachment_get_file_info() e_attachment_get_icon() e_attachment_get_mime_part() e_attachment_get_description() e_attachment_get_thumbnail_path()
Diffstat (limited to 'em-format')
-rw-r--r--em-format/e-mail-formatter-attachment.c12
-rw-r--r--em-format/e-mail-formatter-print.c11
-rw-r--r--em-format/e-mail-parser.c4
3 files changed, 15 insertions, 12 deletions
diff --git a/em-format/e-mail-formatter-attachment.c b/em-format/e-mail-formatter-attachment.c
index 1003b55eef..fb997c0230 100644
--- a/em-format/e-mail-formatter-attachment.c
+++ b/em-format/e-mail-formatter-attachment.c
@@ -198,17 +198,17 @@ emfe_attachment_format (EMailFormatterExtension *extension,
if (context->mode == E_MAIL_FORMATTER_MODE_PRINTING) {
gchar *name;
EAttachment *attachment;
- GFileInfo *fi;
- const gchar *description;
+ GFileInfo *file_info;
const gchar *display_name;
+ gchar *description;
attachment = e_mail_part_attachment_ref_attachment (
E_MAIL_PART_ATTACHMENT (part));
- fi = e_attachment_get_file_info (attachment);
- display_name = g_file_info_get_display_name (fi);
+ file_info = e_attachment_ref_file_info (attachment);
+ display_name = g_file_info_get_display_name (file_info);
- description = e_attachment_get_description (attachment);
+ description = e_attachment_dup_description (attachment);
if (description != NULL && *description != '\0') {
name = g_strdup_printf (
"<h2>Attachment: %s (%s)</h2>\n",
@@ -222,9 +222,11 @@ emfe_attachment_format (EMailFormatterExtension *extension,
camel_stream_write_string (
stream, name, cancellable, NULL);
+ g_free (description);
g_free (name);
g_object_unref (attachment);
+ g_object_unref (file_info);
}
for (iter = g_queue_peek_head_link (extensions); iter; iter = iter->next) {
diff --git a/em-format/e-mail-formatter-print.c b/em-format/e-mail-formatter-print.c
index 0728cb6a8e..4d5c303d03 100644
--- a/em-format/e-mail-formatter-print.c
+++ b/em-format/e-mail-formatter-print.c
@@ -57,20 +57,21 @@ mail_formatter_print_write_attachments (EMailFormatter *formatter,
EMailPartAttachment *part;
EAttachment *attachment;
GFileInfo *file_info;
- gchar *name, *size;
- const gchar *description;
const gchar *display_name;
+ gchar *description;
+ gchar *name;
+ gchar *size;
part = g_queue_pop_head (attachments);
attachment = e_mail_part_attachment_ref_attachment (part);
- file_info = e_attachment_get_file_info (attachment);
+ file_info = e_attachment_ref_file_info (attachment);
if (file_info == NULL) {
g_object_unref (attachment);
continue;
}
- description = e_attachment_get_description (attachment);
+ description = e_attachment_dup_description (attachment);
display_name = g_file_info_get_display_name (file_info);
if (description != NULL && *description != '\0') {
@@ -86,10 +87,12 @@ mail_formatter_print_write_attachments (EMailFormatter *formatter,
str, "<tr><td>%s</td><td>%s</td></tr>\n",
name, size);
+ g_free (description);
g_free (name);
g_free (size);
g_object_unref (attachment);
+ g_object_unref (file_info);
}
g_string_append (str, "</table>\n");
diff --git a/em-format/e-mail-parser.c b/em-format/e-mail-parser.c
index f31e0ca199..57c362e286 100644
--- a/em-format/e-mail-parser.c
+++ b/em-format/e-mail-parser.c
@@ -734,14 +734,12 @@ e_mail_parser_wrap_as_attachment (EMailParser *parser,
if (size != 0) {
GFileInfo *file_info;
- file_info = e_attachment_get_file_info (attachment);
+ file_info = e_attachment_ref_file_info (attachment);
if (file_info == NULL) {
file_info = g_file_info_new ();
g_file_info_set_content_type (
file_info, empa->snoop_mime_type);
- } else {
- g_object_ref (file_info);
}
g_file_info_set_size (file_info, size);