[libadwaita/libadwaita-1-0] swipe-tracker: fix memory leak



commit d7784e2eb957bd3c2081b93fe8ae5e14ea7b55b9
Author: George Barrett <bob bob131 so>
Date:   Fri May 13 08:27:04 2022 +1000

    swipe-tracker: fix memory leak
    
    AdwSwipeTracker allocates a GArray to hold event history but never
    frees it. This commit adds a finalize implementation that ensures the
    array gets freed.
    
    Fixes 689b873411a6b5e3ed7dc67569feee62e479c5de.
    
    
    (cherry picked from commit 61a0488b10026af8067f970dcbfdf8bdeee71c56)
    
    (cherry picked from commit 3e8dda92173c5b7047a6ff5c207f03263eae3a68)

 src/adw-swipe-tracker.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/src/adw-swipe-tracker.c b/src/adw-swipe-tracker.c
index 7825e881..e874407d 100644
--- a/src/adw-swipe-tracker.c
+++ b/src/adw-swipe-tracker.c
@@ -905,6 +905,16 @@ adw_swipe_tracker_dispose (GObject *object)
   G_OBJECT_CLASS (adw_swipe_tracker_parent_class)->dispose (object);
 }
 
+static void
+adw_swipe_tracker_finalize (GObject *object)
+{
+  AdwSwipeTracker *self = ADW_SWIPE_TRACKER (object);
+
+  g_array_free (self->event_history, TRUE);
+
+  G_OBJECT_CLASS (adw_swipe_tracker_parent_class)->finalize (object);
+}
+
 static void
 adw_swipe_tracker_get_property (GObject    *object,
                                 guint       prop_id,
@@ -988,6 +998,7 @@ adw_swipe_tracker_class_init (AdwSwipeTrackerClass *klass)
 
   object_class->constructed = adw_swipe_tracker_constructed;
   object_class->dispose = adw_swipe_tracker_dispose;
+  object_class->finalize = adw_swipe_tracker_finalize;
   object_class->get_property = adw_swipe_tracker_get_property;
   object_class->set_property = adw_swipe_tracker_set_property;
 


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