From f98514d5ed4254e9adfd6d525d21c34e561d89e2 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sat, 27 Jul 2013 01:34:42 +0200 Subject: [PATCH] Increase reference in zathura_page_widget_update_surface and always destroy in render. Signed-off-by: Sebastian Ramacher --- page-widget.c | 4 +++- render.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/page-widget.c b/page-widget.c index 0c95624..75694a6 100644 --- a/page-widget.c +++ b/page-widget.c @@ -505,11 +505,13 @@ zathura_page_widget_update_surface(ZathuraPage* widget, cairo_surface_t* surface zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget); mutex_lock(&(priv->lock)); if (priv->surface != NULL) { - cairo_surface_finish(priv->surface); cairo_surface_destroy(priv->surface); } priv->render_requested = false; priv->surface = surface; + if (priv->surface != NULL) { + cairo_surface_reference(surface); + } mutex_unlock(&(priv->lock)); /* force a redraw here */ if (priv->surface != NULL) { diff --git a/render.c b/render.c index b2ad38b..e8bcde3 100644 --- a/render.c +++ b/render.c @@ -266,10 +266,10 @@ render(zathura_t* zathura, zathura_page_t* page) GtkWidget* widget = zathura_page_get_widget(zathura, page); zathura_page_widget_update_surface(ZATHURA_PAGE(widget), surface); gdk_threads_leave(); - } else { - cairo_surface_destroy(surface); } + cairo_surface_destroy(surface); + return true; }