From 9e2c25c1a40ae34f7b7530c69fcd4dc9cfc5c139 Mon Sep 17 00:00:00 2001 From: Alexander Schwinn Date: Sat, 29 Jun 2019 00:05:03 +0200 Subject: [PATCH] Dont restart the folder monitor on each refresh - Fixes "ghost files after moving files" (Bug #13364) --- thunar/thunar-folder.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/thunar/thunar-folder.c b/thunar/thunar-folder.c index 9a751747..d40cfa4c 100644 --- a/thunar/thunar-folder.c +++ b/thunar/thunar-folder.c @@ -407,7 +407,6 @@ thunar_folder_files_ready (ThunarJob *job, { _thunar_return_val_if_fail (THUNAR_IS_FOLDER (folder), FALSE); _thunar_return_val_if_fail (THUNAR_IS_JOB (job), FALSE); - _thunar_return_val_if_fail (folder->monitor == NULL, FALSE); /* merge the list with the existing list of new files */ folder->new_files = g_list_concat (folder->new_files, files); @@ -485,7 +484,6 @@ thunar_folder_finished (ExoJob *job, _thunar_return_if_fail (THUNAR_IS_FOLDER (folder)); _thunar_return_if_fail (THUNAR_IS_JOB (job)); _thunar_return_if_fail (THUNAR_IS_FILE (folder->corresponding_file)); - _thunar_return_if_fail (folder->monitor == NULL); _thunar_return_if_fail (folder->content_type_idle_id == 0); /* check if we need to merge new files with existing files */ @@ -583,11 +581,14 @@ thunar_folder_finished (ExoJob *job, /* restart the content type idle loader */ thunar_folder_content_type_loader (folder); - /* add us to the file alteration monitor */ - folder->monitor = g_file_monitor_directory (thunar_file_get_file (folder->corresponding_file), + if (folder->monitor == NULL) + { + /* add us to the folder alteration monitor */ + folder->monitor = g_file_monitor_directory (thunar_file_get_file (folder->corresponding_file), G_FILE_MONITOR_SEND_MOVED, NULL, NULL); - if (G_LIKELY (folder->monitor != NULL)) - g_signal_connect (folder->monitor, "changed", G_CALLBACK (thunar_folder_monitor), folder); + if (G_LIKELY (folder->monitor != NULL)) + g_signal_connect (folder->monitor, "changed", G_CALLBACK (thunar_folder_monitor), folder); + } /* tell the consumers that we have loaded the directory */ g_object_notify (G_OBJECT (folder), "loading"); @@ -736,7 +737,6 @@ thunar_folder_monitor (GFileMonitor *monitor, _thunar_return_if_fail (G_IS_FILE_MONITOR (monitor)); _thunar_return_if_fail (THUNAR_IS_FOLDER (folder)); _thunar_return_if_fail (folder->monitor == monitor); - _thunar_return_if_fail (folder->job == NULL); _thunar_return_if_fail (THUNAR_IS_FILE (folder->corresponding_file)); _thunar_return_if_fail (G_IS_FILE (event_file)); @@ -814,9 +814,6 @@ thunar_folder_monitor (GFileMonitor *monitor, g_object_unref (file); } } - - /* reload the folder of the source file */ - thunar_file_reload (folder->corresponding_file); } else { @@ -993,15 +990,6 @@ thunar_folder_reload (ThunarFolder *folder, folder->job = NULL; } - /* disconnect from the file alteration monitor */ - if (G_UNLIKELY (folder->monitor != NULL)) - { - g_signal_handlers_disconnect_matched (folder->monitor, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, folder); - g_file_monitor_cancel (folder->monitor); - g_object_unref (folder->monitor); - folder->monitor = NULL; - } - /* reset the new_files list */ thunar_g_file_list_free (folder->new_files); folder->new_files = NULL; -- 2.11.0