[mutter] wayland: Clean up presentation-time state



commit 806e64dcb07aab73ee8ca60a1b294260ce3ab39b
Author: Michel Dänzer <mdaenzer redhat com>
Date:   Sat Jul 23 17:00:09 2022 +0200

    wayland: Clean up presentation-time state
    
    Fixes memory leak:
    
    ==995170== 288 (96 direct, 192 indirect) bytes in 1 blocks are definitely lost in loss record 14,607 of 
15,641
    ==995170==    at 0x483F7B5: malloc (vg_replace_malloc.c:381)
    ==995170==    by 0x4B21178: g_malloc (gmem.c:125)
    ==995170==    by 0x4B395C0: g_slice_alloc (gslice.c:1072)
    ==995170==    by 0x4B0766D: g_hash_table_new_full (ghash.c:1071)
    ==995170==    by 0x4A4F973: meta_wayland_init_presentation_time (meta-wayland-presentation-time.c:222)
    ==995170==    by 0x4A3FB04: meta_wayland_compositor_new (meta-wayland.c:635)
    ==995170==    by 0x49C7FA7: meta_context_start (meta-context.c:412)
    ==995170==    by 0x10F065: main (mutter.c:148)
    
    Fixes: dccc60ec3e04 ("wayland: Implement stub presentation-time")
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2527>

 src/wayland/meta-wayland-presentation-time-private.h |  2 ++
 src/wayland/meta-wayland-presentation-time.c         | 15 +++++++++++++++
 src/wayland/meta-wayland.c                           |  1 +
 3 files changed, 18 insertions(+)
---
diff --git a/src/wayland/meta-wayland-presentation-time-private.h 
b/src/wayland/meta-wayland-presentation-time-private.h
index bc3dc6a40f..a4d8bfa607 100644
--- a/src/wayland/meta-wayland-presentation-time-private.h
+++ b/src/wayland/meta-wayland-presentation-time-private.h
@@ -49,6 +49,8 @@ typedef struct _MetaWaylandPresentationTime
   GHashTable *feedbacks;
 } MetaWaylandPresentationTime;
 
+void meta_wayland_presentation_time_finalize (MetaWaylandCompositor *compositor);
+
 void meta_wayland_init_presentation_time (MetaWaylandCompositor *compositor);
 
 void meta_wayland_presentation_feedback_discard (MetaWaylandPresentationFeedback *feedback);
diff --git a/src/wayland/meta-wayland-presentation-time.c b/src/wayland/meta-wayland-presentation-time.c
index 70c90e0dfd..fb99445eb7 100644
--- a/src/wayland/meta-wayland-presentation-time.c
+++ b/src/wayland/meta-wayland-presentation-time.c
@@ -209,6 +209,21 @@ on_monitors_changed (MetaMonitorManager    *manager,
   g_hash_table_remove_all (compositor->presentation_time.feedbacks);
 }
 
+void
+meta_wayland_presentation_time_finalize (MetaWaylandCompositor *compositor)
+{
+  MetaBackend *backend = meta_context_get_backend (compositor->context);
+  MetaMonitorManager *monitor_manager =
+    meta_backend_get_monitor_manager (backend);
+
+  g_hash_table_destroy (compositor->presentation_time.feedbacks);
+
+  g_signal_handlers_disconnect_by_func (monitor_manager, on_monitors_changed,
+                                        compositor);
+  g_signal_handlers_disconnect_by_func (monitor_manager, on_after_paint,
+                                        compositor);
+}
+
 void
 meta_wayland_init_presentation_time (MetaWaylandCompositor *compositor)
 {
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index 89ce831f50..fb800f589f 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -449,6 +449,7 @@ meta_wayland_compositor_finalize (GObject *object)
   ClutterActor *stage = meta_backend_get_stage (backend);
 
   meta_wayland_activation_finalize (compositor);
+  meta_wayland_presentation_time_finalize (compositor);
 
   g_hash_table_destroy (compositor->scheduled_surface_associations);
 


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