diff --git a/gio/glocalfilemonitor.c b/gio/glocalfilemonitor.c index 4f85fea52..f408d0707 100644 --- a/gio/glocalfilemonitor.c +++ b/gio/glocalfilemonitor.c @@ -348,7 +348,6 @@ g_file_monitor_source_handle_event (GFileMonitorSource *fms, gint64 event_time) { gboolean interesting = TRUE; - GFileMonitor *instance = NULL; g_assert (!child || is_basename (child)); g_assert (!rename_to || is_basename (rename_to)); @@ -359,13 +358,11 @@ g_file_monitor_source_handle_event (GFileMonitorSource *fms, g_mutex_lock (&fms->lock); - /* monitor is already gone -- don't bother */ - instance = g_weak_ref_get (&fms->instance_ref); - if (instance == NULL) - { - g_mutex_unlock (&fms->lock); - return TRUE; - } + /* NOTE: We process events even if the file monitor has already been disposed. + * The reason is that we must not take a reference to the instance here + * as destroying it from the event handling thread will lead to a + * deadlock when taking the lock in _ih_sub_cancel. + */ switch (event_type) { @@ -452,7 +449,6 @@ g_file_monitor_source_handle_event (GFileMonitorSource *fms, g_file_monitor_source_update_ready_time (fms); g_mutex_unlock (&fms->lock); - g_clear_object (&instance); return interesting; }