[evolution] Bug 792688 - Failed mail print operation causes crash
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 792688 - Failed mail print operation causes crash
- Date: Tue, 27 Mar 2018 13:22:47 +0000 (UTC)
commit b0cce4fd8fbac03050720670ff6d1033a359df55
Author: Milan Crha <mcrha redhat com>
Date: Tue Mar 27 15:24:17 2018 +0200
Bug 792688 - Failed mail print operation causes crash
src/mail/e-mail-printer.c | 27 +++++++++++++++------------
1 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/src/mail/e-mail-printer.c b/src/mail/e-mail-printer.c
index 69a628c..f47f329 100644
--- a/src/mail/e-mail-printer.c
+++ b/src/mail/e-mail-printer.c
@@ -51,6 +51,7 @@ struct _EMailPrinterPrivate {
struct _AsyncContext {
WebKitWebView *web_view;
gulong load_status_handler_id;
+ GError *error;
GtkPrintOperationResult print_result;
};
@@ -83,6 +84,7 @@ async_context_free (AsyncContext *async_context)
async_context->load_status_handler_id);
g_clear_object (&async_context->web_view);
+ g_clear_error (&async_context->error);
g_slice_free (AsyncContext, async_context);
}
@@ -170,15 +172,22 @@ mail_printer_print_finished_cb (WebKitPrintOperation *print_operation,
async_context = g_task_get_task_data (task);
g_return_if_fail (async_context != NULL);
- async_context->print_result = GTK_PRINT_OPERATION_RESULT_APPLY;
- g_task_return_boolean (task, TRUE);
+ if (async_context->print_result == GTK_PRINT_OPERATION_RESULT_IN_PROGRESS) {
+ async_context->print_result = GTK_PRINT_OPERATION_RESULT_APPLY;
+ g_task_return_boolean (task, TRUE);
+ } else if (async_context->error) {
+ g_task_return_error (task, g_error_copy (async_context->error));
+ } else {
+ g_task_return_boolean (task, FALSE);
+ }
+
g_object_unref (task);
}
static void
mail_printer_print_failed_cb (WebKitPrintOperation *print_operation,
- GError *error,
+ const GError *error,
GTask *task)
{
AsyncContext *async_context;
@@ -189,15 +198,7 @@ mail_printer_print_failed_cb (WebKitPrintOperation *print_operation,
async_context = g_task_get_task_data (task);
g_return_if_fail (async_context != NULL);
async_context->print_result = GTK_PRINT_OPERATION_RESULT_ERROR;
-
- if (error != NULL)
- g_task_return_error (task, error);
- else {
- g_warning ("WebKit print operation returned ERROR result without setting a GError");
- g_task_return_boolean (task, FALSE);
- }
-
- g_object_unref (task);
+ async_context->error = error ? g_error_copy (error) : NULL;
}
static gboolean
@@ -530,6 +531,8 @@ e_mail_printer_print (EMailPrinter *printer,
/* EMailFormatter can be NULL. */
async_context = g_slice_new0 (AsyncContext);
+ async_context->print_result = GTK_PRINT_OPERATION_RESULT_IN_PROGRESS;
+ async_context->error = NULL;
part_list = e_mail_printer_ref_part_list (printer);
folder = e_mail_part_list_get_folder (part_list);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]