Fix a memory leak around buttons in Colors prefs page.
authorAndrej Kacian <ticho@claws-mail.org>
Tue, 11 Jul 2017 15:35:44 +0000 (17:35 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Tue, 11 Jul 2017 15:51:13 +0000 (17:51 +0200)
src/gtk/gtkutils.c
src/prefs_msg_colors.c

index f3c7aba..14fa92e 100644 (file)
@@ -864,6 +864,7 @@ void gtkut_set_widget_bgcolor_rgb(GtkWidget *widget, guint rgbvalue)
        newstyle->bg[GTK_STATE_PRELIGHT] = gdk_color;
        newstyle->bg[GTK_STATE_ACTIVE]   = gdk_color;
        gtk_widget_set_style(widget, newstyle);
+       gtk_style_unref(newstyle);
 }
   
 /*!
@@ -1254,6 +1255,7 @@ GtkWidget *gtkut_get_link_btn(GtkWidget *window, const gchar *url, const gchar *
                style->fg[GTK_STATE_ACTIVE]   = uri_color[1];
                style->fg[GTK_STATE_PRELIGHT] = uri_color[0];
                gtk_widget_set_style(btn_label, style);
+               gtk_style_unref(style);
 #if !GTK_CHECK_VERSION(3, 0, 0)
        } else
                g_warning("color allocation failed");
index 79ca383..13ba614 100644 (file)
@@ -444,6 +444,7 @@ static void prefs_msg_colors_create_widget(PrefsPage *_page, GtkWindow *window,
 
                CLAWS_SET_TIP(color_buttons.custom_color[c],
                                     tooltip_btn_text);
+               g_free(tooltip_btn_text);
 
                entry_custom_colorlabel[c] = gtk_entry_new();
                gtk_widget_show (entry_custom_colorlabel[c]);
@@ -451,6 +452,7 @@ static void prefs_msg_colors_create_widget(PrefsPage *_page, GtkWindow *window,
                                   FALSE, FALSE, 0);
                CLAWS_SET_TIP(entry_custom_colorlabel[c],
                                     tooltip_entry_text);
+               g_free(tooltip_entry_text);
        }
 
        for (c = (COLORLABELS>>1)+(COLORLABELS&1); c < COLORLABELS; c++) {
@@ -474,6 +476,7 @@ static void prefs_msg_colors_create_widget(PrefsPage *_page, GtkWindow *window,
                                   FALSE, FALSE, 0);
                CLAWS_SET_TIP(color_buttons.custom_color[c],
                                     tooltip_btn_text);
+               g_free(tooltip_btn_text);
 
                entry_custom_colorlabel[c] = gtk_entry_new();
                gtk_widget_show (entry_custom_colorlabel[c]);
@@ -481,10 +484,10 @@ static void prefs_msg_colors_create_widget(PrefsPage *_page, GtkWindow *window,
                                   FALSE, FALSE, 0);
                CLAWS_SET_TIP(entry_custom_colorlabel[c],
                                     tooltip_entry_text);
+
+               g_free(tooltip_entry_text);
        }
 
-       g_free(tooltip_btn_text);
-       g_free(tooltip_entry_text);
 
        hbox_reset_custom_colors = gtk_hbox_new(FALSE, VBOX_BORDER);
        gtk_widget_show (hbox_reset_custom_colors);
@@ -775,6 +778,7 @@ static void set_button_bg_color(GtkWidget *widget, gint rgbvalue)
        newstyle->bg[GTK_STATE_ACTIVE]   = color;
 
        gtk_widget_set_style(GTK_WIDGET(widget), newstyle);
+       gtk_style_unref(newstyle);
 }
 
 static void prefs_msg_colors_save(PrefsPage *_page)