Skip to content

Commit

Permalink
Check for failed rendering jobs
Browse files Browse the repository at this point in the history
Check whether creating of thumbnails for sidebar, thumbnails for recent view
or rendering of document itself failed to avoid crashes.

https://bugzilla.gnome.org/show_bug.cgi?id=744049

https://bugzilla.gnome.org/show_bug.cgi?id=744586
  • Loading branch information
Marek Kasik authored and Felipe Borges committed Oct 16, 2015
1 parent 28f8be7 commit f93a84c
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 5 deletions.
8 changes: 5 additions & 3 deletions libdocument/ev-document.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,11 +724,13 @@ _ev_document_get_thumbnail (EvDocument *document,
EvRenderContext *rc)
{
cairo_surface_t *surface;
GdkPixbuf *pixbuf;
GdkPixbuf *pixbuf = NULL;

surface = ev_document_render (document, rc);
pixbuf = ev_document_misc_pixbuf_from_surface (surface);
cairo_surface_destroy (surface);
if (surface != NULL) {
pixbuf = ev_document_misc_pixbuf_from_surface (surface);
cairo_surface_destroy (surface);
}

return pixbuf;
}
Expand Down
26 changes: 25 additions & 1 deletion libview/ev-jobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,21 @@ ev_job_render_run (EvJob *job)
g_object_unref (ev_page);

job_render->surface = ev_document_render (job->document, rc);

if (job_render->surface == NULL) {
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);

return FALSE;
}

/* If job was cancelled during the page rendering,
* we return now, so that the thread is finished ASAP
*/
Expand Down Expand Up @@ -873,7 +888,16 @@ ev_job_thumbnail_run (EvJob *job)
g_object_unref (pixbuf);
}

ev_job_succeeded (job);
if ((job_thumb->format == EV_JOB_THUMBNAIL_PIXBUF && pixbuf == NULL) ||
job_thumb->thumbnail_surface == NULL) {
ev_job_failed (job,
EV_DOCUMENT_ERROR,
EV_DOCUMENT_ERROR_INVALID,
_("Failed to create thumbnail for page %d"),
job_thumb->page);
} else {
ev_job_succeeded (job);
}

return FALSE;
}
Expand Down
6 changes: 6 additions & 0 deletions libview/ev-pixbuf-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,12 @@ job_finished_cb (EvJob *job,

job_info = find_job_cache (pixbuf_cache, job_render->page);

if (ev_job_is_failed (job)) {
job_info->job = NULL;
g_object_unref (job);
return;
}

copy_job_to_job_info (job_render, job_info, pixbuf_cache);
g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
}
Expand Down
3 changes: 2 additions & 1 deletion shell/ev-recent-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ static void
thumbnail_job_completed_callback (EvJobThumbnail *job,
GetDocumentInfoAsyncData *data)
{
if (g_cancellable_is_cancelled (data->cancellable)) {
if (g_cancellable_is_cancelled (data->cancellable) ||
ev_job_is_failed (EV_JOB (job))) {
get_document_info_async_data_free (data);
return;
}
Expand Down
5 changes: 5 additions & 0 deletions shell/ev-sidebar-thumbnails.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,12 @@ thumbnail_job_completed_callback (EvJobThumbnail *job,
cairo_surface_t *surface;
#ifdef HAVE_HIDPI_SUPPORT
gint device_scale;
#endif

if (ev_job_is_failed (EV_JOB (job)))
return;

#ifdef HAVE_HIDPI_SUPPORT
device_scale = gtk_widget_get_scale_factor (widget);
cairo_surface_set_device_scale (job->thumbnail_surface, device_scale, device_scale);
#endif
Expand Down

0 comments on commit f93a84c

Please sign in to comment.