summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Miranda <andreldm@xfce.org>2017-11-03 22:41:19 -0300
committerAndre Miranda <andreldm@xfce.org>2017-11-03 22:47:15 -0300
commitab50af40ef2d02f49e7f54a35ab41d4c0d80fbff (patch)
tree693ac0ea54a10b92cf2d5bca94b8343e0ed28043
parent7792a3fbba7f21fd9b226116c85d8b4d1785165f (diff)
downloadthunar-ab50af40ef2d02f49e7f54a35ab41d4c0d80fbff.tar.gz
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.
-rw-r--r--thunar/thunar-file.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index 5eac91d7..46d0dc72 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)
{