From afab9d238a8b7e1b3bbcea9047431ae6395ecf65 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 12 Dec 2014 13:34:20 +0100 Subject: Bug 724039 - Message preview shows a wrong message diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c index 07ac192..acf5124 100644 --- a/mail/e-mail-reader-utils.c +++ b/mail/e-mail-reader-utils.c @@ -957,6 +957,7 @@ mail_reader_print_parse_message_cb (GObject *source_object, EMailPrinter *printer; EMailPartList *part_list; AsyncContext *async_context; + GError *local_error = NULL; reader = E_MAIL_READER (source_object); async_context = (AsyncContext *) user_data; @@ -964,7 +965,17 @@ mail_reader_print_parse_message_cb (GObject *source_object, activity = async_context->activity; cancellable = e_activity_get_cancellable (activity); - part_list = e_mail_reader_parse_message_finish (reader, result); + part_list = e_mail_reader_parse_message_finish (reader, result, &local_error); + + if (local_error) { + g_warn_if_fail (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)); + + e_activity_handle_cancellation (activity, local_error); + g_clear_error (&local_error); + async_context_free (async_context); + + return; + } printer = e_mail_printer_new (part_list); @@ -1650,10 +1661,21 @@ mail_reader_reply_message_parsed (GObject *object, EMsgComposer *composer; CamelMimeMessage *message; AsyncContext *async_context; + GError *local_error = NULL; async_context = (AsyncContext *) user_data; - part_list = e_mail_reader_parse_message_finish (reader, result); + part_list = e_mail_reader_parse_message_finish (reader, result, &local_error); + + if (local_error) { + g_warn_if_fail (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)); + + g_clear_error (&local_error); + async_context_free (async_context); + + return; + } + message = e_mail_part_list_get_message (part_list); backend = e_mail_reader_get_backend (async_context->reader); @@ -2351,6 +2373,7 @@ mail_reader_parse_message_run (GSimpleAsyncResult *simple, EMailPartList *part_list; AsyncContext *async_context; gchar *mail_uri; + GError *local_error = NULL; async_context = g_simple_async_result_get_op_res_gpointer (simple); @@ -2389,6 +2412,9 @@ mail_reader_parse_message_run (GSimpleAsyncResult *simple, g_free (mail_uri); async_context->part_list = part_list; + + if (g_cancellable_set_error_if_cancelled (cancellable, &local_error)) + g_simple_async_result_take_error (simple, local_error); } void @@ -2438,7 +2464,8 @@ e_mail_reader_parse_message (EMailReader *reader, EMailPartList * e_mail_reader_parse_message_finish (EMailReader *reader, - GAsyncResult *result) + GAsyncResult *result, + GError **error) { GSimpleAsyncResult *simple; AsyncContext *async_context; @@ -2449,6 +2476,10 @@ e_mail_reader_parse_message_finish (EMailReader *reader, e_mail_reader_parse_message), NULL); simple = G_SIMPLE_ASYNC_RESULT (result); + + if (g_simple_async_result_propagate_error (simple, error)) + return NULL; + async_context = g_simple_async_result_get_op_res_gpointer (simple); if (async_context->part_list != NULL) diff --git a/mail/e-mail-reader-utils.h b/mail/e-mail-reader-utils.h index 32c6ae0..18f937b 100644 --- a/mail/e-mail-reader-utils.h +++ b/mail/e-mail-reader-utils.h @@ -91,7 +91,8 @@ void e_mail_reader_parse_message (EMailReader *reader, gpointer user_data); EMailPartList * e_mail_reader_parse_message_finish (EMailReader *reader, - GAsyncResult *result); + GAsyncResult *result, + GError **error); G_END_DECLS diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 01ad296..cdf549d 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -3091,11 +3091,19 @@ set_mail_display_part_list (GObject *object, EMailPartList *part_list; EMailReader *reader; EMailDisplay *display; + GError *local_error = NULL; reader = E_MAIL_READER (object); display = e_mail_reader_get_mail_display (reader); - part_list = e_mail_reader_parse_message_finish (reader, result); + part_list = e_mail_reader_parse_message_finish (reader, result, &local_error); + + if (local_error) { + g_warn_if_fail (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)); + + g_clear_error (&local_error); + return; + } e_mail_display_set_part_list (display, part_list); e_mail_display_load (display, NULL); -- cgit v0.10.1