diff --git a/zathura/page-widget.c b/zathura/page-widget.c index 6991b91..733f224 100644 --- a/zathura/page-widget.c +++ b/zathura/page-widget.c @@ -733,23 +733,24 @@ draw_thumbnail_image(cairo_surface_t* surface, size_t max_size) const unsigned int unscaled_height = height / device.y; /* create thumbnail surface, taking width and height as _unscaled_ device units */ - cairo_surface_t *thumbnail; + cairo_surface_t* thumbnail; thumbnail = cairo_surface_create_similar(surface, CAIRO_CONTENT_COLOR, unscaled_width, unscaled_height); - if (thumbnail == NULL) { + if (cairo_surface_status(thumbnail) != CAIRO_STATUS_SUCCESS) { return NULL; } - cairo_t *cr = cairo_create(thumbnail); - if (cr == NULL) { + + cairo_t* cairo = cairo_create(thumbnail); + if (cairo_status(cairo) != CAIRO_STATUS_SUCCESS) { cairo_surface_destroy(thumbnail); return NULL; } - cairo_scale(cr, scale, scale); - cairo_set_source_surface(cr, surface, 0, 0); - cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_BILINEAR); - cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); - cairo_paint(cr); - cairo_destroy(cr); + cairo_scale(cairo, scale, scale); + cairo_set_source_surface(cairo, surface, 0, 0); + cairo_pattern_set_filter(cairo_get_source(cairo), CAIRO_FILTER_BILINEAR); + cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); + cairo_paint(cairo); + cairo_destroy(cairo); return thumbnail; } diff --git a/zathura/print.c b/zathura/print.c index 03c9a43..b14fdd6 100644 --- a/zathura/print.c +++ b/zathura/print.c @@ -52,16 +52,12 @@ draw_page_image(cairo_t* cairo, GtkPrintContext* context, zathura_t* zathura, const double page_height = zathura_page_get_height(page) * scale_height; const double page_width = zathura_page_get_width(page) * scale_width; cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, page_width, page_height); - if (surface == NULL) { - return false; - } if (cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) { - cairo_surface_destroy(surface); return false; } cairo_t* temp_cairo = cairo_create(surface); - if (cairo == NULL) { + if (cairo_status(temp_cairo) != CAIRO_STATUS_SUCCESS) { cairo_surface_destroy(surface); return false; } @@ -113,9 +109,9 @@ cb_print_draw_page(GtkPrintOperation* print_operation, GtkPrintContext* g_free(tmp); /* Get the page and cairo handle. */ - cairo_t* cairo = gtk_print_context_get_cairo_context(context); zathura_page_t* page = zathura_document_get_page(zathura->document, page_number); - if (cairo == NULL || page == NULL) { + cairo_t* cairo = gtk_print_context_get_cairo_context(context); + if (cairo_status(cairo) != CAIRO_STATUS_SUCCESS || page == NULL) { gtk_print_operation_cancel(print_operation); return; } diff --git a/zathura/render.c b/zathura/render.c index ec2ef7a..04de23d 100644 --- a/zathura/render.c +++ b/zathura/render.c @@ -767,7 +767,7 @@ static bool render_to_cairo_surface(cairo_surface_t* surface, zathura_page_t* page, ZathuraRenderer* renderer, double real_scale) { cairo_t* cairo = cairo_create(surface); - if (cairo == NULL) { + if (cairo_status(cairo) != CAIRO_STATUS_SUCCESS) { return false; } @@ -833,11 +833,6 @@ render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* render } cairo_surface_t* surface = cairo_image_surface_create(format, page_width, page_height); - - if (surface == NULL) { - return false; - } - if (request_priv->render_plain == false) { cairo_surface_set_device_scale(surface, device_factors.x, device_factors.y); }