From c1064da33a50208ec27fe6ddd6fedcf2930db064 Mon Sep 17 00:00:00 2001 From: Vladimir Chren Date: Thu, 9 Feb 2017 11:00:58 +0100 Subject: [PATCH] Fix object unreferencing (bug #12260) Object unreferencing is now called only after deferred function using the object returns. --- thunar/thunar-file.c | 22 ++++++++++++++++++++++ thunar/thunar-file.h | 1 + thunar/thunar-job.c | 3 +-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index c2a89d8..c7aae58 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -3988,6 +3988,28 @@ thunar_file_reload_idle (ThunarFile *file) /** + * thunar_file_reload_idle_unref: + * @file : a #ThunarFile instance. + * + * Schedules a reload of the @file by calling thunar_file_reload + * when idle. When scheduled function returns @file object will be + * unreferenced. + * + **/ +void +thunar_file_reload_idle_unref (ThunarFile *file) +{ + _thunar_return_if_fail (THUNAR_IS_FILE (file)); + + g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, + (GSourceFunc) thunar_file_reload, + file, + (GDestroyNotify) g_object_unref); +} + + + +/** * thunar_file_destroy: * @file : a #ThunarFile instance. * diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h index cfc3d05..da5b2a4 100644 --- a/thunar/thunar-file.h +++ b/thunar/thunar-file.h @@ -241,6 +241,7 @@ void thunar_file_unwatch (ThunarFile gboolean thunar_file_reload (ThunarFile *file); void thunar_file_reload_idle (ThunarFile *file); +void thunar_file_reload_idle_unref (ThunarFile *file); void thunar_file_reload_parent (ThunarFile *file); void thunar_file_destroy (ThunarFile *file); diff --git a/thunar/thunar-job.c b/thunar/thunar-job.c index f4ce28e..aa84cb3 100644 --- a/thunar/thunar-job.c +++ b/thunar/thunar-job.c @@ -578,8 +578,7 @@ thunar_job_new_files (ThunarJob *job, file = thunar_file_cache_lookup (lp->data); if (file != NULL) { - thunar_file_reload_idle (file); - g_object_unref (file); + thunar_file_reload_idle_unref (file); } } -- 2.7.4