From ba59bcd0dc08b8d2bba144cba8021d228b05664a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Thu, 17 Sep 2009 18:03:18 +0000 Subject: [PATCH] Plug a small memory leak and improve function signature of add_page_header(). git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4207 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 2 ++ src/printing.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e09ca34d..e9ec1a57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ * src/printing.c: Fix wrong alignment of printed pages when page headers are disabled (closes #2856822). + Plug a small memory leak and improve function signature of + add_page_header(). 2009-09-17 Nick Treleaven diff --git a/src/printing.c b/src/printing.c index 3081ce04..a9b074f0 100644 --- a/src/printing.c +++ b/src/printing.c @@ -270,7 +270,7 @@ static gint get_page_count(GtkPrintContext *context, DocInfo *dinfo) } -static void add_page_header(PangoLayout *layout, cairo_t *cr, DocInfo *dinfo, gint width, gint page_nr) +static void add_page_header(DocInfo *dinfo, cairo_t *cr, gint width, gint page_nr) { gint ph_height = dinfo->line_height * 3; gchar *data; @@ -279,6 +279,7 @@ static void add_page_header(PangoLayout *layout, cairo_t *cr, DocInfo *dinfo, gi dinfo->doc->file_name : GEANY_STRING_UNTITLED; gchar *file_name = (printing_prefs.page_header_basename) ? g_path_get_basename(tmp_file_name) : g_strdup(tmp_file_name); + PangoLayout *layout = dinfo->layout; /* draw the frame */ cairo_set_line_width(cr, 0.3); @@ -526,6 +527,7 @@ static void draw_page(GtkPrintOperation *operation, GtkPrintContext *context, gchar *text = g_strdup_printf(_("Page %d of %d"), page_nr, dinfo->n_pages); gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(main_widgets.progressbar), fraction); gtk_progress_bar_set_text(GTK_PROGRESS_BAR(main_widgets.progressbar), text); + g_free(text); } #ifdef GEANY_PRINT_DEBUG @@ -552,7 +554,7 @@ static void draw_page(GtkPrintOperation *operation, GtkPrintContext *context, pango_layout_set_justify(dinfo->layout, FALSE); if (printing_prefs.print_page_header) - add_page_header(dinfo->layout, cr, dinfo, width, page_nr); + add_page_header(dinfo, cr, width, page_nr); count = 0; /* the actual line counter for the current page, might be different from * dinfo->cur_line due to possible line breaks */