summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2015-01-16 16:41:21 -0500
committerRyan Lortie <desrt@desrt.ca>2015-03-10 11:53:56 -0400
commita73cfdbee6b52e8c2ac8b079735b58e41edf2fd4 (patch)
tree77676dc23bcff2411fc76c9d2732f7d5035c51b6
parent6c7f942cbf8fa0b9485b8620827c6d4539936251 (diff)
downloadglib-a73cfdbee6b52e8c2ac8b079735b58e41edf2fd4.tar.gz
GPollFileMonitor: use thread default main context
Attach the GPollFileMonitor to the thread default main context instead of the global default. This matches the behaviour of the other file monitors.
-rw-r--r--gio/gpollfilemonitor.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/gio/gpollfilemonitor.c b/gio/gpollfilemonitor.c
index 10c2d86d2..bdc72e384 100644
--- a/gio/gpollfilemonitor.c
+++ b/gio/gpollfilemonitor.c
@@ -35,7 +35,7 @@ struct _GPollFileMonitor
GFileMonitor parent_instance;
GFile *file;
GFileInfo *last_info;
- guint timeout;
+ GSource *timeout;
};
#define POLL_TIME_SECS 5
@@ -171,8 +171,10 @@ poll_file_timeout (gpointer data)
static void
schedule_poll_timeout (GPollFileMonitor* poll_monitor)
{
- poll_monitor->timeout = g_timeout_add_seconds (POLL_TIME_SECS, poll_file_timeout, poll_monitor);
- }
+ poll_monitor->timeout = g_timeout_source_new_seconds (POLL_TIME_SECS);
+ g_source_set_callback (poll_monitor->timeout, poll_file_timeout, poll_monitor, NULL);
+ g_source_attach (poll_monitor->timeout, g_main_context_get_thread_default ());
+}
static void
got_initial_info (GObject *source_object,
@@ -222,8 +224,9 @@ g_poll_file_monitor_cancel (GFileMonitor* monitor)
if (poll_monitor->timeout)
{
- g_source_remove (poll_monitor->timeout);
- poll_monitor->timeout = 0;
+ g_source_destroy (poll_monitor->timeout);
+ g_source_unref (poll_monitor->timeout);
+ poll_monitor->timeout = NULL;
}
return TRUE;