From 9c17d02f6ebfb3d693f7a05bf65f1ff09199a62d Mon Sep 17 00:00:00 2001 From: Alexander Schwinn Date: Thu, 20 Jun 2019 21:28:07 +0200 Subject: [PATCH] After moving files, a Ghost file sometimes remains (Bug #13364) --- thunar/thunar-folder.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/thunar/thunar-folder.c b/thunar/thunar-folder.c index 9a751747..46f09a0e 100644 --- a/thunar/thunar-folder.c +++ b/thunar/thunar-folder.c @@ -83,6 +83,7 @@ static void thunar_folder_monitor (GFileMonitor GFile *other_file, GFileMonitorEvent event_type, gpointer user_data); +static gboolean thunar_folder_reload_delayed (ThunarFolder *folder); @@ -110,6 +111,7 @@ struct _ThunarFolder GList *new_files; GList *files; gboolean reload_info; + gboolean reload_triggered; GList *content_type_ptr; guint content_type_idle_id; @@ -250,6 +252,7 @@ thunar_folder_init (ThunarFolder *folder) folder->monitor = NULL; folder->reload_info = FALSE; + folder->reload_triggered = FALSE; } @@ -604,11 +607,16 @@ thunar_folder_file_changed (ThunarFileMonitor *file_monitor, _thunar_return_if_fail (THUNAR_IS_FOLDER (folder)); _thunar_return_if_fail (THUNAR_IS_FILE_MONITOR (file_monitor)); - /* check if the corresponding file changed... */ + /* check if the corresponding file changed. If so, reload the folder*/ if (G_UNLIKELY (folder->corresponding_file == file)) { - /* ...and if so, reload the folder */ - thunar_folder_reload (folder, FALSE); + /* prevent burst-calls */ + if (folder->reload_triggered) + return; + + /* Trigger the reload with 100ms delay (for this time, burst calls will be ignored) */ + g_timeout_add (100, (GSourceFunc) thunar_folder_reload_delayed, folder); + folder->reload_triggered = TRUE; } } @@ -964,6 +972,23 @@ thunar_folder_get_loading (const ThunarFolder *folder) /** + * thunar_folder_reload_delayed: + * @folder : a #ThunarFolder instance. + * + * Wrapper for delayed calls of thunar_folder_reload, to be used with 'g_timeout_add'. + * Note that reload_info is fixed to FALSE for the wrapper. + **/ +static gboolean +thunar_folder_reload_delayed (ThunarFolder *folder) +{ + folder->reload_triggered = FALSE; + thunar_folder_reload (folder, FALSE); + return FALSE; +} + + + +/** * thunar_folder_reload: * @folder : a #ThunarFolder instance. * @reload_info : reload all information for the files too -- 2.11.0