[Xfce4-commits] [xfce/thunar] 02/02: Handle cases when file watch is not supported (Bug #13881)

noreply at xfce.org noreply at xfce.org
Sat Nov 4 02:46:44 CET 2017


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

a   n   d   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/thunar.

commit a7355a59e2eb5af635f109852216f7d6064ffb70
Author: Andre Miranda <andreldm at xfce.org>
Date:   Fri Nov 3 22:41:19 2017 -0300

    Handle cases when file watch is not supported (Bug #13881)
    
    When a remote folder is accessed, this error is printed:
    (thunar:9378): thunar-CRITICAL **: thunar_file_watch: assertion '...
    
    Upon leaving that folder, Thunar crashes:
    ERROR:thunar-file.c:3929:thunar_file_unwatch: code should not be reached
    
    I found out that a call to g_file_monitor in thunar_file_watch has no
    error handling, and in the case of remote folders this error happens:
    Failed to create file monitor: Operation not supported by backend
    
    So when ThunarFolder is finalized and calls thunar_file_unwatch, its
    file_watch will be NULL and _thunar_assert_not_reached kills Thunar.
---
 thunar/thunar-file.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index 0e058e2..2333d90 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -181,6 +181,9 @@ struct _ThunarFile
 
   /* flags for thumbnail state etc */
   ThunarFileFlags       flags;
+  
+  /* tells whether the file watch is not set */
+  gboolean              no_file_watch;
 };
 
 typedef struct
@@ -3875,6 +3878,7 @@ void
 thunar_file_watch (ThunarFile *file)
 {
   ThunarFileWatch *file_watch;
+  GError          *error = NULL;
 
   _thunar_return_if_fail (THUNAR_IS_FILE (file));
 
@@ -3885,8 +3889,14 @@ thunar_file_watch (ThunarFile *file)
       file_watch->watch_count = 1;
 
       /* create a file or directory monitor */
-      file_watch->monitor = g_file_monitor (file->gfile, G_FILE_MONITOR_WATCH_MOUNTS | G_FILE_MONITOR_SEND_MOVED, NULL, NULL);
-      if (G_LIKELY (file_watch->monitor != NULL))
+      file_watch->monitor = g_file_monitor (file->gfile, G_FILE_MONITOR_WATCH_MOUNTS | G_FILE_MONITOR_SEND_MOVED, NULL, &error);
+      if (G_UNLIKELY (file_watch->monitor == NULL))
+        {
+          g_debug ("Failed to create file monitor: %s", error->message);
+          g_error_free (error);
+          file->no_file_watch = TRUE;
+        }
+      else
         {
           /* watch monitor for file changes */
           g_signal_connect (file_watch->monitor, "changed", G_CALLBACK (thunar_file_monitor), file);
@@ -3895,7 +3905,7 @@ thunar_file_watch (ThunarFile *file)
       /* attach to file */
       g_object_set_qdata_full (G_OBJECT (file), thunar_file_watch_quark, file_watch, thunar_file_watch_destroyed);
     }
-  else
+  else if (G_LIKELY (!file->no_file_watch))
     {
       /* increase watch count */
       _thunar_return_if_fail (G_IS_FILE_MONITOR (file_watch->monitor));
@@ -3919,6 +3929,11 @@ thunar_file_unwatch (ThunarFile *file)
 
   _thunar_return_if_fail (THUNAR_IS_FILE (file));
 
+  if (G_UNLIKELY (file->no_file_watch))
+    {
+      return;
+    }
+
   file_watch = g_object_get_qdata (G_OBJECT (file), thunar_file_watch_quark);
   if (file_watch != NULL)
     {

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


More information about the Xfce4-commits mailing list