summaryrefslogtreecommitdiff
path: root/libview
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-12-09 15:50:09 +0100
committerinfirit <[email protected]>2014-12-09 23:02:28 +0100
commit0412a5fb05ca8726129a5f6f4d2ef599e804e444 (patch)
treeb24a2005ded1dc46de884b263e41ab8c042135f4 /libview
parent0f7517f8ba18c8952d052e6d23a3822b3d9f4ec6 (diff)
downloadatril-0412a5fb05ca8726129a5f6f4d2ef599e804e444.tar.bz2
atril-0412a5fb05ca8726129a5f6f4d2ef599e804e444.tar.xz
libview: make sure gtk_print_operation_cancel() is called from draw-page callback
Fixes crash when printing operation is cancelled. Taken from evince commit: a09aa79195825d5d9c80c36362203c7c36a5e914 From: Carlos Garcia Campos <[email protected]> Gnome bug: https://bugzilla.gnome.org/show_bug.cgi?id=635619
Diffstat (limited to 'libview')
-rw-r--r--libview/ev-print-operation.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/libview/ev-print-operation.c b/libview/ev-print-operation.c
index 3cec253a..6b972f4e 100644
--- a/libview/ev-print-operation.c
+++ b/libview/ev-print-operation.c
@@ -1628,7 +1628,10 @@ ev_print_operation_print_cancel (EvPrintOperation *op)
{
EvPrintOperationPrint *print = EV_PRINT_OPERATION_PRINT (op);
- gtk_print_operation_cancel (print->op);
+ if (print->job_print)
+ ev_job_cancel (print->job_print);
+ else
+ gtk_print_operation_cancel (print->op);
}
static void
@@ -1707,11 +1710,30 @@ print_job_finished (EvJobPrint *job,
ev_job_print_set_cairo (job, NULL);
}
+static gboolean
+draw_page_finish_idle (EvPrintOperationPrint *print)
+{
+ if (ev_job_scheduler_get_running_thread_job () == print->job_print)
+ return TRUE;
+
+ gtk_print_operation_draw_page_finish (print->op);
+
+ return FALSE;
+}
+
static void
print_job_cancelled (EvJobPrint *job,
- EvPrintOperationPrint *print)
+ EvPrintOperationPrint *print)
{
- gtk_print_operation_cancel (print->op);
+ /* Finish the current page, so that draw-page
+ * is emitted again and it will cancel the
+ * print operation. If the job is still
+ * running, wait until it finishes.
+ */
+ if (ev_job_scheduler_get_running_thread_job () == print->job_print)
+ g_idle_add ((GSourceFunc)draw_page_finish_idle, print);
+ else
+ gtk_print_operation_draw_page_finish (print->op);
}
static void
@@ -1776,10 +1798,14 @@ ev_print_operation_print_draw_page (EvPrintOperationPrint *print,
g_signal_connect (G_OBJECT (print->job_print), "finished",
G_CALLBACK (print_job_finished),
(gpointer)print);
- g_signal_connect (G_OBJECT (print->job_print), "cancelled",
- G_CALLBACK (print_job_cancelled),
- (gpointer)print);
- }
+ g_signal_connect (G_OBJECT (print->job_print), "cancelled",
+ G_CALLBACK (print_job_cancelled),
+ (gpointer)print);
+ } else if (g_cancellable_is_cancelled (print->job_print->cancellable)) {
+ gtk_print_operation_cancel (print->op);
+ ev_job_print_set_cairo (EV_JOB_PRINT (print->job_print), NULL);
+ return;
+ }
ev_job_print_set_page (EV_JOB_PRINT (print->job_print), page);