diff options
author | Philip Withnall <withnall@endlessm.com> | 2019-10-11 21:33:47 +0100 |
---|---|---|
committer | Philip Withnall <withnall@endlessm.com> | 2019-10-11 22:31:24 +0100 |
commit | bffe058550fc31ad372858ac805ca6f7cf7c2aab (patch) | |
tree | 9e1ea81d743c945122b40fdb41cff94046bee798 /gio/glocalfilemonitor.c | |
parent | c7dd1ae04055001ad48cb9da371fa8131118f3b3 (diff) |
gdesktopappinfo: Allocate DesktopFileDir structs dynamically
`DesktopFileDir` pointers are passed around between threads: they are
initially created on the main thread, but a pointer to them is passed to
the GLib worker thread in the file monitor callback
(`desktop_file_dir_changed()`).
Accordingly, the `DesktopFileDir` objects either have to be
(1) immutable;
(2) reference counted; or
(3) synchronised between the two threads
to avoid one of them being used by one thread after being freed on
another. Option (1) changed with commit 99bc33b6 and is no longer an
option. Option (3) would mean blocking the main thread on the worker
thread, which would be hard to achieve and is against the point of
having a worker thread. So that leaves option (2), which is implemented
here.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Fixes: #1903
Diffstat (limited to 'gio/glocalfilemonitor.c')
-rw-r--r-- | gio/glocalfilemonitor.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/gio/glocalfilemonitor.c b/gio/glocalfilemonitor.c index 897d5f244..ce17179f6 100644 --- a/gio/glocalfilemonitor.c +++ b/gio/glocalfilemonitor.c @@ -887,6 +887,7 @@ g_local_file_monitor_new_in_worker (const gchar *pathname, GFileMonitorFlags flags, GFileMonitorCallback callback, gpointer user_data, + GClosureNotify destroy_user_data, GError **error) { GLocalFileMonitor *monitor; @@ -899,7 +900,8 @@ g_local_file_monitor_new_in_worker (const gchar *pathname, if (monitor) { if (callback) - g_signal_connect (monitor, "changed", G_CALLBACK (callback), user_data); + g_signal_connect_data (monitor, "changed", G_CALLBACK (callback), + user_data, destroy_user_data, 0 /* flags */); g_local_file_monitor_start (monitor, pathname, is_directory, flags, GLIB_PRIVATE_CALL(g_get_worker_context) ()); } |