summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiselle Reis <[email protected]>2014-08-30 00:23:04 +0200
committerraveit65 <[email protected]>2019-12-08 19:16:54 +0100
commit1e9f259b8e5cee2750fb42c4469112560e5b23ce (patch)
treeebba2f65f02fa70108c5a09e4df29e49e2b6b81e
parent018d33c2c8c863ecdbfa46c52e9ff374c24ae6f3 (diff)
downloadatril-1e9f259b8e5cee2750fb42c4469112560e5b23ce.tar.bz2
atril-1e9f259b8e5cee2750fb42c4469112560e5b23ce.tar.xz
libview: fixing memory leak
The memory leak was caused by a g_signal_connect which was never disconnected. This patch makes sure the signal is disconnected and the job is cancelled before creating another rendering job. It additionally introduces a helper function to cleanly finalize the job. origin commit: https://gitlab.gnome.org/GNOME/evince/commit/939c434
-rw-r--r--libview/ev-pixbuf-cache.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/libview/ev-pixbuf-cache.c b/libview/ev-pixbuf-cache.c
index 99e5b731..a8e98f9f 100644
--- a/libview/ev-pixbuf-cache.c
+++ b/libview/ev-pixbuf-cache.c
@@ -164,20 +164,27 @@ ev_pixbuf_cache_finalize (GObject *object)
}
static void
+end_job (CacheJobInfo *job_info,
+ gpointer data)
+{
+ g_signal_handlers_disconnect_by_func (job_info->job,
+ G_CALLBACK (job_finished_cb),
+ data);
+ ev_job_cancel (job_info->job);
+ g_object_unref (job_info->job);
+ job_info->job = NULL;
+}
+
+static void
dispose_cache_job_info (CacheJobInfo *job_info,
gpointer data)
{
if (job_info == NULL)
return;
- if (job_info->job) {
- g_signal_handlers_disconnect_by_func (job_info->job,
- G_CALLBACK (job_finished_cb),
- data);
- ev_job_cancel (job_info->job);
- g_object_unref (job_info->job);
- job_info->job = NULL;
- }
+ if (job_info->job)
+ end_job (job_info, data);
+
if (job_info->surface) {
cairo_surface_destroy (job_info->surface);
job_info->surface = NULL;
@@ -308,14 +315,8 @@ copy_job_to_job_info (EvJobRender *job_render,
job_info->points_set = TRUE;
}
- if (job_info->job) {
- g_signal_handlers_disconnect_by_func (job_info->job,
- G_CALLBACK (job_finished_cb),
- pixbuf_cache);
- ev_job_cancel (job_info->job);
- g_object_unref (job_info->job);
- job_info->job = NULL;
- }
+ if (job_info->job)
+ end_job (job_info, pixbuf_cache);
job_info->page_ready = TRUE;
}
@@ -368,12 +369,7 @@ check_job_size_and_unref (EvPixbufCache *pixbuf_cache,
return;
}
- g_signal_handlers_disconnect_by_func (job_info->job,
- G_CALLBACK (job_finished_cb),
- pixbuf_cache);
- ev_job_cancel (job_info->job);
- g_object_unref (job_info->job);
- job_info->job = NULL;
+ end_job (job_info, pixbuf_cache);
}
/* Do all function that copies a job from an older cache to it's position in the
@@ -683,6 +679,9 @@ add_job (EvPixbufCache *pixbuf_cache,
cairo_region_destroy (job_info->region);
job_info->region = region ? cairo_region_reference (region) : NULL;
+ if (job_info->job)
+ end_job (job_info, pixbuf_cache);
+
job_info->job = ev_job_render_new (pixbuf_cache->document,
page, rotation,
scale * job_info->device_scale,