Fix a memory leak when setting summaryview and folderview fonts.
authorAndrej Kacian <ticho@claws-mail.org>
Fri, 9 Sep 2016 23:32:47 +0000 (01:32 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Fri, 9 Sep 2016 23:32:47 +0000 (01:32 +0200)
src/folderview.c
src/summaryview.c

index 83dc219..42c3fe0 100644 (file)
@@ -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));
index 57511b3..bd62243 100644 (file)
@@ -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);