From 3805496dbbdaad3d988d8582c244743ab1175f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erick=20P=C3=A9rez=20Castellanos?= Date: Sun, 19 Oct 2014 20:08:05 -0400 Subject: [PATCH] event-widget: fix memory leak. According to valgrind pango leaks memory when creating a PangoLayout using gtk_widget_create_pango_layout with a literal string. --- src/gcal-event-widget.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gcal-event-widget.c b/src/gcal-event-widget.c index c0807b20..b612af86 100644 --- a/src/gcal-event-widget.c +++ b/src/gcal-event-widget.c @@ -393,12 +393,11 @@ gcal_event_widget_get_preferred_height (GtkWidget *widget, GtkBorder margin; GtkBorder padding; PangoLayout *layout; - PangoRectangle logical_rect; + gint height; - layout = gtk_widget_create_pango_layout (widget, "00:00:00 00:00"); + layout = gtk_widget_create_pango_layout (widget, NULL); - pango_layout_get_extents (layout, NULL, &logical_rect); - pango_extents_to_pixels (&logical_rect, NULL); + pango_layout_get_pixel_size (layout, NULL, &height); gtk_style_context_get_margin (gtk_widget_get_style_context (widget), gtk_widget_get_state_flags (widget), @@ -408,7 +407,7 @@ gcal_event_widget_get_preferred_height (GtkWidget *widget, &padding); *minimum = *natural = - logical_rect.height + padding.top + padding.bottom + margin.top + margin.bottom; + height + padding.top + padding.bottom + margin.top + margin.bottom; g_object_unref (layout); }