From 3327207c9d840b0a6f6dd297484811dbb98dfe4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erick=20P=C3=A9rez=20Castellanos?= Date: Thu, 6 Jun 2013 10:21:02 -0400 Subject: [PATCH] gcal-window: fixed memory leak when handling date Fixed construction method --- src/gcal-window.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/gcal-window.c b/src/gcal-window.c index c00a7161..21ced28a 100644 --- a/src/gcal-window.c +++ b/src/gcal-window.c @@ -245,9 +245,6 @@ gcal_window_constructed (GObject *object) priv = GCAL_WINDOW (object)->priv; - /* internal data init */ - priv->active_date = g_new (icaltimetype, 1); - /* ui construction */ priv->main_box = gtk_grid_new (); gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->main_box), @@ -386,6 +383,8 @@ gcal_window_set_property (GObject *object, g_value_get_enum (value)); return; case PROP_ACTIVE_DATE: + if (priv->active_date != NULL) + g_free (priv->active_date); priv->active_date = g_value_dup_boxed (value); return; } @@ -1281,18 +1280,18 @@ gcal_window_new_with_view (GcalApplication *app, { GcalWindow *win; GcalManager *manager; + icaltimetype date; + + manager = gcal_application_get_manager (GCAL_APPLICATION (app)); + /* FIXME: here read the initial date from somewehere */ + date = icaltime_current_time_with_zone (gcal_manager_get_system_timezone (manager)); win = g_object_new (GCAL_TYPE_WINDOW, "application", GTK_APPLICATION (app), + "active-date", + &date, NULL); - gcal_window_set_sources_view (win); - - manager = gcal_window_get_manager (win); - - /* FIXME: here read the initial date from somewehere */ - *(win->priv->active_date) = - icaltime_current_time_with_zone (gcal_manager_get_system_timezone (manager)); /* hooking signals */ g_signal_connect (manager,