talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 6061cc33f76e265600a72923c1a2368d00f9c1d2
parent 720b9a5429ea3ddfb5af01400eb67b9d2abac0a2
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Sat, 10 Sep 2016 01:32:47 +0200

Fix a memory leak when setting summaryview and folderview fonts.

Diffstat:
Msrc/folderview.c | 15+++++++++++++--
Msrc/summaryview.c | 19++++++++++++++++---
2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/src/folderview.c b/src/folderview.c @@ -2717,8 +2717,19 @@ void folderview_reflect_prefs(void) last_boldfont = g_strdup(BOLD_FONT); last_derive = prefs_common.derive_from_normal_font; - normal_style = normal_color_style = bold_style = - bold_color_style = bold_tgtfold_style = NULL; +#define STYLE_FREE(s) \ + if (s != NULL) { \ + g_object_unref(s); \ + s = NULL; \ + } + + STYLE_FREE(normal_style); + STYLE_FREE(normal_color_style); + STYLE_FREE(bold_style); + STYLE_FREE(bold_color_style); + STYLE_FREE(bold_tgtfold_style); + +#undef STYLE_FREE folderview_init(folderview); gtk_cmclist_freeze(GTK_CMCLIST(folderview->ctree)); diff --git a/src/summaryview.c b/src/summaryview.c @@ -2881,12 +2881,25 @@ void summary_reflect_prefs(void) last_boldfont = g_strdup(BOLD_FONT); last_derive = prefs_common.derive_from_normal_font; - if (update_font) { - bold_style = bold_marked_style = bold_deleted_style = - small_style = small_marked_style = small_deleted_style = NULL; +#define STYLE_FREE(s) \ + if (s != NULL) { \ + g_object_unref(s); \ + s = NULL; \ + } + + if (update_font) { + STYLE_FREE(bold_style); + STYLE_FREE(bold_style); + STYLE_FREE(bold_marked_style); + STYLE_FREE(bold_deleted_style); + STYLE_FREE(small_style); + STYLE_FREE(small_marked_style); + STYLE_FREE(small_deleted_style); summary_set_fonts(summaryview); } +#undef STYLE_FREE + summary_set_column_titles(summaryview); summary_relayout(summaryview);