[mutter] wayland: Clean up xdg-activation state



commit b329dce0701d2e12ca922398cf7559c7695edd1e
Author: Michel Dänzer <mdaenzer redhat com>
Date:   Sat Jul 23 16:52:52 2022 +0200

    wayland: Clean up xdg-activation state
    
    Fixes memory leak:
    
    ==995170== 240 (48 direct, 192 indirect) bytes in 1 blocks are definitely lost in loss record 14,428 of 
15,641
    ==995170==    at 0x48445EF: calloc (vg_replace_malloc.c:1328)
    ==995170==    by 0x4B211D0: g_malloc0 (gmem.c:155)
    ==995170==    by 0x4A3CDB3: meta_wayland_activation_init (meta-wayland-activation.c:383)
    ==995170==    by 0x4A3FB0C: meta_wayland_compositor_new (meta-wayland.c:636)
    ==995170==    by 0x49C7FA7: meta_context_start (meta-context.c:412)
    ==995170==    by 0x10F065: main (mutter.c:148)
    
    Fixes: ec390b68c5b8 ("wayland: Implement the xdg-activation protocol")
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2527>

 src/wayland/meta-wayland-activation.c | 7 +++++++
 src/wayland/meta-wayland-activation.h | 2 ++
 src/wayland/meta-wayland.c            | 2 ++
 3 files changed, 11 insertions(+)
---
diff --git a/src/wayland/meta-wayland-activation.c b/src/wayland/meta-wayland-activation.c
index 5741b958f9..73faa19142 100644
--- a/src/wayland/meta-wayland-activation.c
+++ b/src/wayland/meta-wayland-activation.c
@@ -375,6 +375,13 @@ bind_activation (struct wl_client *client,
                   wl_resource_get_link (resource));
 }
 
+void
+meta_wayland_activation_finalize (MetaWaylandCompositor *compositor)
+{
+  g_hash_table_destroy (compositor->activation->tokens);
+  g_clear_pointer (&compositor->activation, g_free);
+}
+
 void
 meta_wayland_activation_init (MetaWaylandCompositor *compositor)
 {
diff --git a/src/wayland/meta-wayland-activation.h b/src/wayland/meta-wayland-activation.h
index 8fcc0fa42e..ed4e67737a 100644
--- a/src/wayland/meta-wayland-activation.h
+++ b/src/wayland/meta-wayland-activation.h
@@ -27,6 +27,8 @@
 
 #include "wayland/meta-wayland-types.h"
 
+void meta_wayland_activation_finalize (MetaWaylandCompositor *compositor);
+
 void meta_wayland_activation_init (MetaWaylandCompositor *compositor);
 
 #endif /* META_WAYLAND_ACTIVATION_H */
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index fff07b7784..89ce831f50 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -448,6 +448,8 @@ meta_wayland_compositor_finalize (GObject *object)
   MetaBackend *backend = meta_context_get_backend (compositor->context);
   ClutterActor *stage = meta_backend_get_stage (backend);
 
+  meta_wayland_activation_finalize (compositor);
+
   g_hash_table_destroy (compositor->scheduled_surface_associations);
 
   g_signal_handlers_disconnect_by_func (stage, on_after_update, compositor);


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