[glib/wip/mount-watcher] GFileMonitor: send final CHANGED on CHANGES_DONE
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/mount-watcher] GFileMonitor: send final CHANGED on CHANGES_DONE
- Date: Thu, 15 Jan 2015 16:43:50 +0000 (UTC)
commit 7538468ab805ec6788ebbe478747b69be23cf1ac
Author: Ryan Lortie <desrt desrt ca>
Date: Thu Jan 15 11:41:08 2015 -0500
GFileMonitor: send final CHANGED on CHANGES_DONE
CHANGES_DONE would delete the pending change record, ignoring the dirty
flag. That means that a rate-limited CHANGED event would effectively be
dropped. Fix up that inconsistency by reporting the CHANGED before the
CHANGES_DONE if the dirty bit was set.
gio/glocalfilemonitor.c | 26 ++++++++++++++++++++------
1 files changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/gio/glocalfilemonitor.c b/gio/glocalfilemonitor.c
index 44b24a6..e860167 100644
--- a/gio/glocalfilemonitor.c
+++ b/gio/glocalfilemonitor.c
@@ -178,22 +178,32 @@ g_file_monitor_source_add_pending_change (GFileMonitorSource *fms,
}
static void
-g_file_monitor_source_update_pending_change (GFileMonitorSource *fms,
- GSequenceIter *iter,
- gboolean dirty)
+g_file_monitor_source_set_pending_change_dirty (GFileMonitorSource *fms,
+ GSequenceIter *iter)
{
PendingChange *change;
change = g_sequence_get (iter);
- if (change->dirty != dirty)
+ if (!change->dirty)
{
- change->dirty = dirty;
+ change->dirty = TRUE;
g_sequence_sort_changed (iter, pending_change_compare_ready_time, fms);
}
}
+static gboolean
+g_file_monitor_source_get_pending_change_dirty (GFileMonitorSource *fms,
+ GSequenceIter *iter)
+{
+ PendingChange *change;
+
+ change = g_sequence_get (iter);
+
+ return change->dirty;
+}
+
static void
g_file_monitor_source_remove_pending_change (GFileMonitorSource *fms,
GSequenceIter *iter,
@@ -242,7 +252,7 @@ g_file_monitor_source_file_changed (GFileMonitorSource *fms,
g_file_monitor_source_add_pending_change (fms, child, now);
}
else
- g_file_monitor_source_update_pending_change (fms, pending, TRUE);
+ g_file_monitor_source_set_pending_change_dirty (fms, pending);
g_file_monitor_source_update_ready_time (fms);
}
@@ -256,6 +266,10 @@ g_file_monitor_source_file_changes_done (GFileMonitorSource *fms,
pending = g_file_monitor_source_find_pending_change (fms, child);
if (pending)
{
+ /* If it is dirty, make sure we push out the last CHANGED event */
+ if (g_file_monitor_source_get_pending_change_dirty (fms, pending))
+ g_file_monitor_source_queue_event (fms, G_FILE_MONITOR_EVENT_CHANGED, child, NULL);
+
g_file_monitor_source_queue_event (fms, G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT, child, NULL);
g_file_monitor_source_remove_pending_change (fms, pending, child);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]