From ad0d70d5d5bfbbc91f692b578afc1b41465fa18b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 28 Oct 2021 15:30:41 +0200 Subject: [PATCH] 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: --- src/wayland/meta-wayland-private.h | 2 ++ src/wayland/meta-wayland.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/wayland/meta-wayland-private.h b/src/wayland/meta-wayland-private.h index 5272b530f..35fad8692 100644 --- a/src/wayland/meta-wayland-private.h +++ b/src/wayland/meta-wayland-private.h @@ -86,6 +86,8 @@ struct _MetaWaylandCompositor struct wl_display *wayland_display; char *display_name; + GSource *source; + GHashTable *outputs; GList *frame_callback_surfaces; diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c index 3381a497e..dccf0da10 100644 --- a/src/wayland/meta-wayland.c +++ b/src/wayland/meta-wayland.c @@ -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);