[mutter] wayland: Detach event source on tear down



commit ad0d70d5d5bfbbc91f692b578afc1b41465fa18b
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Thu Oct 28 15:30:41 2021 +0200

    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>

 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 5272b530f1..35fad86922 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 3381a497e6..dccf0da106 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]