Permalink
Browse files

Fix crash and hang while renaming

  • Loading branch information...
1 parent b4826a8 commit b838a4d250e3283590cabac2ee5947cdf91c8864 pgkos committed with ochosi Jan 31, 2017
Showing with 18 additions and 2 deletions.
  1. +11 −2 thunar/thunar-file.c
  2. +7 −0 thunar/thunar-folder.c
View
@@ -121,6 +121,7 @@ static gboolean thunar_file_same_filesystem (const ThunarFile
G_LOCK_DEFINE_STATIC (file_cache_mutex);
G_LOCK_DEFINE_STATIC (file_content_type_mutex);
+G_LOCK_DEFINE_STATIC (file_rename_mutex);
@@ -780,7 +781,9 @@ thunar_file_monitor (GFileMonitor *monitor,
/* the event occurred for the monitored ThunarFile */
if (event_type == G_FILE_MONITOR_EVENT_MOVED)
{
+ G_LOCK (file_rename_mutex);
thunar_file_monitor_moved (file, other_path);
+ G_UNLOCK (file_rename_mutex);
return;
}
@@ -797,6 +800,9 @@ thunar_file_monitor (GFileMonitor *monitor,
/* reload the target file if cached */
if (other_path == NULL)
return;
+
+ G_LOCK (file_rename_mutex);
+
other_file = thunar_file_cache_lookup (other_path);
if (other_file)
thunar_file_reload (other_file);
@@ -813,13 +819,14 @@ thunar_file_monitor (GFileMonitor *monitor,
thunar_file_reload_parent (other_file);
g_object_unref (other_file);
+
+ G_UNLOCK (file_rename_mutex);
}
return;
}
}
-
static void
thunar_file_watch_destroyed (gpointer data)
{
@@ -1928,6 +1935,7 @@ thunar_file_rename (ThunarFile *file,
}
else
{
+ G_LOCK (file_rename_mutex);
/* try to rename the file */
renamed_file = g_file_set_display_name (file->gfile, name, cancellable, error);
@@ -1944,11 +1952,12 @@ thunar_file_rename (ThunarFile *file,
/* emit the file changed signal */
thunar_file_changed (file);
}
-
+ G_UNLOCK (file_rename_mutex);
return TRUE;
}
else
{
+ G_UNLOCK (file_rename_mutex);
return FALSE;
}
}
View
@@ -276,6 +276,9 @@ thunar_folder_finalize (GObject *object)
{
ThunarFolder *folder = THUNAR_FOLDER (object);
+ if (folder->corresponding_file)
+ thunar_file_unwatch (folder->corresponding_file);
+
/* disconnect from the ThunarFileMonitor instance */
g_signal_handlers_disconnect_matched (folder->file_monitor, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, folder);
g_object_unref (folder->file_monitor);
@@ -356,7 +359,11 @@ 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);
break;
case PROP_LOADING:

0 comments on commit b838a4d

Please sign in to comment.