[Xfce4-commits] [xfce/thunar] 01/02: Fix crash and hang while renaming

noreply at xfce.org noreply at xfce.org
Thu Feb 9 00:08:47 CET 2017


This is an automated email from the git hooks/post-receive script.

ochosi pushed a commit to branch master
in repository xfce/thunar.

commit b838a4d250e3283590cabac2ee5947cdf91c8864
Author: pgkos <pgkos.bugzilla at yahoo.com>
Date:   Tue Jan 31 19:30:55 2017 +0100

    Fix crash and hang while renaming
---
 thunar/thunar-file.c   | 13 +++++++++++--
 thunar/thunar-folder.c |  7 +++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index c8ca881..ccca2c9 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -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;
         }
     }
diff --git a/thunar/thunar-folder.c b/thunar/thunar-folder.c
index 9decb89..a90988e 100644
--- a/thunar/thunar-folder.c
+++ b/thunar/thunar-folder.c
@@ -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:

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list