[gnome-calendar] date-chooser: Fix GDateTime leak



commit 52a9864cba061fe2c6ddce1991df89c9db90ec20
Author: Victor Toso <me victortoso com>
Date:   Sat Oct 1 00:26:23 2016 +0200

    date-chooser: Fix GDateTime leak
    
    By using finalize and dispose methods and calling the proper free method.
    
    8,806 (64 direct, 8,742 indirect) bytes in 2 blocks are definitely lost in loss record 18,051 of 18,131
       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 0x99E95C1: g_date_time_new (gdatetime.c:957)
       by 0x99E97B2: g_date_time_new_local (gdatetime.c:1012)
       by 0x4251F4: multi_choice_changed (gcal-date-chooser.c:419)
       by 0x9567F16: g_cclosure_marshal_VOID__PARAM (gmarshal.c:1832)
       by 0x95638B9: g_closure_invoke (gclosure.c:804)
       by 0x957FD25: signal_emit_unlocked_R (gsignal.c:3635)
       by 0x957F05C: g_signal_emit_valist (gsignal.c:3391)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772272

 src/gcal-date-chooser.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-date-chooser.c b/src/gcal-date-chooser.c
index c0d4396..b463d56 100644
--- a/src/gcal-date-chooser.c
+++ b/src/gcal-date-chooser.c
@@ -467,6 +467,21 @@ calendar_drag_data_received (GtkWidget        *widget,
 }
 
 static void
+gcal_date_chooser_finalize (GObject *object)
+{
+  GcalDateChooser *self = GCAL_DATE_CHOOSER (object);
+
+  g_clear_pointer (&self->date, g_date_time_unref);
+  G_OBJECT_CLASS (gcal_date_chooser_parent_class)->finalize (object);
+}
+
+static void
+gcal_date_chooser_dispose (GObject *object)
+{
+  G_OBJECT_CLASS (gcal_date_chooser_parent_class)->dispose (object);
+}
+
+static void
 gcal_date_chooser_class_init (GcalDateChooserClass *class)
 {
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
@@ -474,6 +489,8 @@ gcal_date_chooser_class_init (GcalDateChooserClass *class)
 
   g_type_ensure (GCAL_TYPE_MULTI_CHOICE);
 
+  object_class->dispose = gcal_date_chooser_dispose;
+  object_class->finalize = gcal_date_chooser_finalize;
   object_class->set_property = calendar_set_property;
   object_class->get_property = calendar_get_property;
 


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