thread: Push the thread-default main context

Makes g_main_context_get_thread_default() do the right thing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
This commit is contained in:
Jonas Ådahl 2022-12-21 18:00:37 +01:00
parent 59ba952661
commit 0d5d1745ce

View File

@ -297,14 +297,16 @@ thread_impl_func (gpointer user_data)
MetaContext *context = meta_backend_get_context (priv->backend);
MetaThreadImpl *impl = priv->impl;
MetaThreadImplRunFlags run_flags = META_THREAD_IMPL_RUN_FLAG_NONE;
#ifdef HAVE_PROFILER
GMainContext *thread_context = meta_thread_impl_get_main_context (impl);
#ifdef HAVE_PROFILER
MetaProfiler *profiler = meta_context_get_profiler (context);
#endif
g_mutex_lock (&priv->kernel.init_mutex);
g_mutex_unlock (&priv->kernel.init_mutex);
g_main_context_push_thread_default (thread_context);
#ifdef HAVE_PROFILER
meta_profiler_register_thread (profiler, thread_context, priv->name);
#endif
@ -331,6 +333,8 @@ thread_impl_func (gpointer user_data)
meta_profiler_unregister_thread (profiler, thread_context);
#endif
g_main_context_pop_thread_default (thread_context);
return GINT_TO_POINTER (TRUE);
}