wayland: Detach event source on tear down

No reason keeping it attached; would one continue using a main loop on
the default main context after tear down, we'd get callbacks causing
use-after-free issues.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2140>
This commit is contained in:
Jonas Ådahl 2021-10-28 15:30:41 +02:00 committed by Marge Bot
parent 754c834590
commit ad0d70d5d5
2 changed files with 5 additions and 0 deletions

View File

@ -86,6 +86,8 @@ struct _MetaWaylandCompositor
struct wl_display *wayland_display;
char *display_name;
GSource *source;
GHashTable *outputs;
GList *frame_callback_surfaces;

View File

@ -436,6 +436,7 @@ meta_wayland_compositor_finalize (GObject *object)
g_clear_pointer (&compositor->display_name, g_free);
g_clear_pointer (&compositor->wayland_display, wl_display_destroy);
g_clear_pointer (&compositor->source, g_source_destroy);
G_OBJECT_CLASS (meta_wayland_compositor_parent_class)->finalize (object);
}
@ -542,6 +543,8 @@ meta_wayland_compositor_new (MetaContext *context)
*/
g_source_set_priority (wayland_event_source, GDK_PRIORITY_EVENTS + 1);
g_source_attach (wayland_event_source, NULL);
compositor->source = wayland_event_source;
g_source_unref (wayland_event_source);
g_signal_connect (stage, "after-update",
G_CALLBACK (on_after_update), compositor);