[gnome-calendar] time-selector: Fix GDateTime leak



commit f713a90ea3fca2d482a265f08841f7e40f8f7c99
Author: Victor Toso <me victortoso com>
Date:   Sat Oct 1 00:16:20 2016 +0200

    time-selector: Fix GDateTime leak
    
    By using finalize and dispose methods and calling the proper free
    methods calls.
    
    8,806 (64 direct, 8,742 indirect) bytes in 2 blocks are definitely lost in loss record 18,367 of 18,534
       at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
       by 0x9A0C90E: g_malloc (gmem.c:94)
       by 0x9A26A55: g_slice_alloc (gslice.c:1025)
       by 0x9A26A95: g_slice_alloc0 (gslice.c:1051)
       by 0x99E8DC4: g_date_time_alloc (gdatetime.c:428)
       by 0x99E8FA3: g_date_time_from_instant (gdatetime.c:524)
       by 0x99E933F: g_date_time_new_from_timeval (gdatetime.c:647)
       by 0x99E93A5: g_date_time_new_now (gdatetime.c:705)
       by 0x99E93C4: g_date_time_new_now_local (gdatetime.c:728)
       by 0x445BED: gcal_time_selector_init (gcal-time-selector.c:249)
       by 0x9584B32: g_type_create_instance (gtype.c:1866)
       by 0x956BED0: g_object_new_internal (gobject.c:1783)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772272

 src/gcal-time-selector.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-time-selector.c b/src/gcal-time-selector.c
index 781bf9b..54109c8 100644
--- a/src/gcal-time-selector.c
+++ b/src/gcal-time-selector.c
@@ -207,12 +207,29 @@ gcal_time_selector_set_time_format (GcalTimeSelector *selector,
 }
 
 static void
+gcal_time_selector_finalize (GObject *object)
+{
+  GcalTimeSelector *self = GCAL_TIME_SELECTOR (object);
+
+  g_clear_pointer (&self->time, g_date_time_unref);
+  G_OBJECT_CLASS (gcal_time_selector_parent_class)->finalize (object);
+}
+
+static void
+gcal_time_selector_dispose (GObject *object)
+{
+  G_OBJECT_CLASS (gcal_time_selector_parent_class)->dispose (object);
+}
+
+static void
 gcal_time_selector_class_init (GcalTimeSelectorClass *klass)
 {
   GObjectClass *object_class;
 
   object_class = G_OBJECT_CLASS (klass);
   object_class->constructed = gcal_time_selector_constructed;
+  object_class->dispose = gcal_time_selector_dispose;
+  object_class->finalize = gcal_time_selector_finalize;
   object_class->get_property = gcal_time_selector_get_property;
   object_class->set_property = gcal_time_selector_set_property;
 


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