thread: Flush tasks and callbacks on finalize

This will make sure no tasks or callbacks are unexpectedly dropped,
potentially leaking or leaving things in an unexpected state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
This commit is contained in:
Jonas Ådahl
2021-06-11 17:51:50 +02:00
parent 261624538c
commit 251722ec4e
4 changed files with 46 additions and 5 deletions

View File

@ -156,8 +156,8 @@ meta_thread_finalize (GObject *object)
MetaThread *thread = META_THREAD (object);
MetaThreadPrivate *priv = meta_thread_get_instance_private (thread);
g_clear_list (&priv->pending_callbacks,
(GDestroyNotify) meta_thread_callback_data_free);
while (meta_thread_impl_dispatch (priv->impl) > 0);
meta_thread_flush_callbacks (thread);
g_clear_handle_id (&priv->callbacks_source_id, g_source_remove);
g_clear_object (&priv->impl);