[mutter/wip/carlosg/repeat-source-leak] backends/native: Unref/unset key repeat GSource when cleared




commit e0ea726bcc50a61d9a92c7fa6af8d2b6175c89e6
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Apr 23 22:53:27 2021 +0200

    backends/native: Unref/unset key repeat GSource when cleared
    
    This GSource is not being properly unref nor the variable holding it
    cleared. This on one hand leaks the GSource memory, on the other hand
    may triggers warnings in keyboard_repeat() as the source may be
    (reentrantly) cleared, yet we don't exit early as
    seat_impl->repeat_source is never NULL.

 src/backends/native/meta-seat-impl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/src/backends/native/meta-seat-impl.c b/src/backends/native/meta-seat-impl.c
index 9137dc3c9c..ae35a060d4 100644
--- a/src/backends/native/meta-seat-impl.c
+++ b/src/backends/native/meta-seat-impl.c
@@ -244,8 +244,11 @@ meta_seat_impl_clear_repeat_source (MetaSeatImpl *seat_impl)
   if (seat_impl->repeat_source)
     {
       g_source_destroy (seat_impl->repeat_source);
-      g_clear_object (&seat_impl->repeat_device);
+      g_source_unref (seat_impl->repeat_source);
+      seat_impl->repeat_source = NULL;
     }
+
+  g_clear_object (&seat_impl->repeat_device);
 }
 
 static void


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