From 58d323df6b4d766e5868cbdd2dec793c2d1ced67 Mon Sep 17 00:00:00 2001 From: Harald Judt Date: Thu, 9 Apr 2015 13:14:19 +0200 Subject: Reload files changed by jobs in an idle loop (bug #11008) If a file is in the cache, schedule a reload of the file when idle. This way file information gets updated properly when necessary and without any crashes. --- thunar/thunar-file.c | 18 ++++++++++++++++++ thunar/thunar-file.h | 2 +- thunar/thunar-job.c | 14 ++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 9a73108..8c32744 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -3933,6 +3933,24 @@ thunar_file_reload (ThunarFile *file) /** + * thunar_file_reload_idle: + * @file : a #ThunarFile instance. + * + * Schedules a reload of the @file by calling thunar_file_reload + * when idle. + * + **/ +void +thunar_file_reload_idle (ThunarFile *file) +{ + _thunar_return_if_fail (THUNAR_IS_FILE (file)); + + g_idle_add ((GSourceFunc) thunar_file_reload, file); +} + + + +/** * thunar_file_destroy: * @file : a #ThunarFile instance. * diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h index c645330..9a3de17 100644 --- a/thunar/thunar-file.h +++ b/thunar/thunar-file.h @@ -240,7 +240,7 @@ void thunar_file_watch (ThunarFile void thunar_file_unwatch (ThunarFile *file); void thunar_file_reload (ThunarFile *file); - +void thunar_file_reload_idle (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 0cd0c38..f4ce28e 100644 --- a/thunar/thunar-job.c +++ b/thunar/thunar-job.c @@ -564,11 +564,25 @@ void thunar_job_new_files (ThunarJob *job, const GList *file_list) { + ThunarFile *file; + const GList *lp; + _thunar_return_if_fail (THUNAR_IS_JOB (job)); /* check if we have any files */ if (G_LIKELY (file_list != NULL)) { + /* schedule a reload of cached files when idle */ + for (lp = file_list; lp != NULL; lp = lp->next) + { + file = thunar_file_cache_lookup (lp->data); + if (file != NULL) + { + thunar_file_reload_idle (file); + g_object_unref (file); + } + } + /* emit the "new-files" signal */ exo_job_emit (EXO_JOB (job), job_signals[NEW_FILES], 0, file_list); } -- 2.3.5