From d928b6baa60fafd1e10e7d17d6227af718d101fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Sat, 23 Jul 2022 17:13:21 +0200 Subject: [PATCH] wayland: Clean up tablet manager state Fixes memory leak: ==995170== 936 (40 direct, 896 indirect) bytes in 1 blocks are definitely lost in loss record 15,090 of 15,641 ==995170== at 0x48445EF: calloc (vg_replace_malloc.c:1328) ==995170== by 0x4B211D0: g_malloc0 (gmem.c:155) ==995170== by 0x4A56693: meta_wayland_tablet_manager_new (meta-wayland-tablet-manager.c:109) ==995170== by 0x4A56693: meta_wayland_tablet_manager_init (meta-wayland-tablet-manager.c:126) ==995170== by 0x4A3FA95: meta_wayland_compositor_new (meta-wayland.c:626) ==995170== by 0x49C7FA7: meta_context_start (meta-context.c:412) ==995170== by 0x10F065: main (mutter.c:148) Fixes: 745cb6798833 ("wayland: Initialize the MetaWaylandTabletManager") Part-of: --- src/wayland/meta-wayland-tablet-manager.c | 6 +++--- src/wayland/meta-wayland-tablet-manager.h | 2 +- src/wayland/meta-wayland.c | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/wayland/meta-wayland-tablet-manager.c b/src/wayland/meta-wayland-tablet-manager.c index 7ee1c9fe7..c8aae5d74 100644 --- a/src/wayland/meta-wayland-tablet-manager.c +++ b/src/wayland/meta-wayland-tablet-manager.c @@ -127,10 +127,10 @@ meta_wayland_tablet_manager_init (MetaWaylandCompositor *compositor) } void -meta_wayland_tablet_manager_free (MetaWaylandTabletManager *tablet_manager) +meta_wayland_tablet_manager_finalize (MetaWaylandCompositor *compositor) { - g_hash_table_destroy (tablet_manager->seats); - g_free (tablet_manager); + g_hash_table_destroy (compositor->tablet_manager->seats); + g_clear_pointer (&compositor->tablet_manager, g_free); } static MetaWaylandTabletSeat * diff --git a/src/wayland/meta-wayland-tablet-manager.h b/src/wayland/meta-wayland-tablet-manager.h index 83f9d3d0f..6491fbcbc 100644 --- a/src/wayland/meta-wayland-tablet-manager.h +++ b/src/wayland/meta-wayland-tablet-manager.h @@ -37,7 +37,7 @@ struct _MetaWaylandTabletManager }; void meta_wayland_tablet_manager_init (MetaWaylandCompositor *compositor); -void meta_wayland_tablet_manager_free (MetaWaylandTabletManager *tablet_manager); +void meta_wayland_tablet_manager_finalize (MetaWaylandCompositor *compositor); gboolean meta_wayland_tablet_manager_consumes_event (MetaWaylandTabletManager *manager, const ClutterEvent *event); diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c index f8b23fec8..4cc2248d3 100644 --- a/src/wayland/meta-wayland.c +++ b/src/wayland/meta-wayland.c @@ -451,6 +451,7 @@ meta_wayland_compositor_finalize (GObject *object) meta_wayland_activation_finalize (compositor); meta_wayland_outputs_finalize (compositor); meta_wayland_presentation_time_finalize (compositor); + meta_wayland_tablet_manager_finalize (compositor); g_hash_table_destroy (compositor->scheduled_surface_associations);