Skip to content

Commit

Permalink
Dont restart the folder monitor on each refresh
Browse files Browse the repository at this point in the history
- Fixes "ghost files after moving files" (Bug #13364)
  • Loading branch information
Alexander Schwinn committed Jul 11, 2019
1 parent 4d6b472 commit c53d11d
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions thunar/thunar-folder.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,22 @@ G_DEFINE_TYPE (ThunarFolder, thunar_folder, G_TYPE_OBJECT)



static void
thunar_folder_constructed (GObject *object)
{
ThunarFolder *folder = THUNAR_FOLDER (object);

/* 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);

G_OBJECT_CLASS (thunar_folder_parent_class)->constructed (object);
}



static void
thunar_folder_class_init (ThunarFolderClass *klass)
{
Expand All @@ -142,6 +158,7 @@ thunar_folder_class_init (ThunarFolderClass *klass)
gobject_class->finalize = thunar_folder_finalize;
gobject_class->get_property = thunar_folder_get_property;
gobject_class->set_property = thunar_folder_set_property;
gobject_class->constructed = thunar_folder_constructed;

klass->destroy = thunar_folder_real_destroy;

Expand Down Expand Up @@ -359,8 +376,6 @@ thunar_folder_set_property (GObject *object,
switch (prop_id)
{
case PROP_CORRESPONDING_FILE:
if (folder->corresponding_file)
thunar_file_unwatch (folder->corresponding_file);
folder->corresponding_file = g_value_dup_object (value);
if (folder->corresponding_file)
thunar_file_watch (folder->corresponding_file);
Expand Down Expand Up @@ -407,7 +422,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);
Expand Down Expand Up @@ -485,7 +499,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 */
Expand Down Expand Up @@ -583,12 +596,6 @@ 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),
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);

/* tell the consumers that we have loaded the directory */
g_object_notify (G_OBJECT (folder), "loading");
}
Expand Down Expand Up @@ -736,7 +743,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));

Expand Down Expand Up @@ -814,9 +820,6 @@ thunar_folder_monitor (GFileMonitor *monitor,
g_object_unref (file);
}
}

/* reload the folder of the source file */
thunar_file_reload (folder->corresponding_file);
}
else
{
Expand Down Expand Up @@ -993,15 +996,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;
Expand Down

0 comments on commit c53d11d

Please sign in to comment.