[evince/wip/chpe/mr-329: 6/6] libview: Do not draw invalid surface




commit 8f7a7a1477c296ec54ad3a61af7b8a1713ea494f
Author: Marek Kasik <mkasik redhat com>
Date:   Wed May 12 16:01:27 2021 +0100

    libview: Do not draw invalid surface
    
    Fail the render job if the surface is in error state. This prevents
    the failure of the render job leaking out to failing to render the
    evince UI.
    
    Based on a patch by Marek Kasik <mkasik redhat com>.

 libview/ev-jobs.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/libview/ev-jobs.c b/libview/ev-jobs.c
index e52e49c81..0795eb0d8 100644
--- a/libview/ev-jobs.c
+++ b/libview/ev-jobs.c
@@ -636,16 +636,27 @@ ev_job_render_run (EvJob *job)
 
        job_render->surface = ev_document_render (job->document, rc);
 
-       if (job_render->surface == NULL) {
+       if (job_render->surface == NULL ||
+           cairo_surface_status (job_render->surface) != CAIRO_STATUS_SUCCESS) {
                ev_document_fc_mutex_unlock ();
                ev_document_doc_mutex_unlock ();
                g_object_unref (rc);
 
-               ev_job_failed (job,
-                              EV_DOCUMENT_ERROR,
-                              EV_DOCUMENT_ERROR_INVALID,
-                              _("Failed to render page %d"),
-                              job_render->page);
+                if (job_render->surface != NULL) {
+                        cairo_status_t status = cairo_surface_status (job_render->surface);
+                        ev_job_failed (job,
+                                       EV_DOCUMENT_ERROR,
+                                       EV_DOCUMENT_ERROR_INVALID,
+                                       _("Failed to render page %d: %s"),
+                                       job_render->page,
+                                       cairo_status_to_string (status));
+                } else {
+                        ev_job_failed (job,
+                                       EV_DOCUMENT_ERROR,
+                                       EV_DOCUMENT_ERROR_INVALID,
+                                       _("Failed to render page %d"),
+                                       job_render->page);
+                }
 
                return FALSE;
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]