From f14f6ecef4778d442eeb9f21a475b43c43978efa Mon Sep 17 00:00:00 2001 From: Andrej Kacian Date: Tue, 11 Jul 2017 17:35:44 +0200 Subject: [PATCH] Fix a memory leak around buttons in Colors prefs page. --- src/gtk/gtkutils.c | 2 ++ src/prefs_msg_colors.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gtk/gtkutils.c b/src/gtk/gtkutils.c index f3c7aba38..14fa92ec7 100644 --- a/src/gtk/gtkutils.c +++ b/src/gtk/gtkutils.c @@ -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"); diff --git a/src/prefs_msg_colors.c b/src/prefs_msg_colors.c index 79ca3832c..13ba614c0 100644 --- a/src/prefs_msg_colors.c +++ b/src/prefs_msg_colors.c @@ -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) -- 2.25.1