Skip to content
Permalink
Browse files

panel-gtk: Fix memory leaks

'g_strconcat' needs to be freed
  • Loading branch information...
sc0w committed Dec 2, 2018
1 parent 76d6eff commit 9628efb30335fc08cd58bd8c51a8e84f18cf8b95
Showing with 14 additions and 4 deletions.
  1. +14 −4 mate-panel/libpanel-util/panel-gtk.c
@@ -183,6 +183,7 @@ GtkWidget *
panel_image_menu_item_new_from_icon (const gchar *icon_name,
const gchar *label_name)
{
gchar *concat;
GtkWidget *icon;
GtkStyleContext *context;
GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
@@ -193,7 +194,8 @@ panel_image_menu_item_new_from_icon (const gchar *icon_name,
else
icon = gtk_image_new ();

GtkWidget *label_menu = gtk_label_new_with_mnemonic (g_strconcat (label_name, " ", NULL));
concat = g_strconcat (label_name, " ", NULL);
GtkWidget *label_menu = gtk_label_new_with_mnemonic (concat);
GtkWidget *menuitem = gtk_menu_item_new ();

context = gtk_widget_get_style_context (GTK_WIDGET(icon_box));
@@ -210,13 +212,16 @@ panel_image_menu_item_new_from_icon (const gchar *icon_name,
g_settings_bind (icon_settings, "menus-have-icons", icon, "visible",
G_SETTINGS_BIND_GET);

g_free (concat);

return menuitem;
}

GtkWidget *
panel_image_menu_item_new_from_gicon (GIcon *gicon,
const gchar *label_name)
{
gchar *concat;
GtkWidget *icon;
GtkStyleContext *context;
GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
@@ -227,7 +232,8 @@ panel_image_menu_item_new_from_gicon (GIcon *gicon,
else
icon = gtk_image_new ();

GtkWidget *label_menu = gtk_label_new_with_mnemonic (g_strconcat (label_name, " ", NULL));
concat = g_strconcat (label_name, " ", NULL);
GtkWidget *label_menu = gtk_label_new_with_mnemonic (concat);
GtkWidget *menuitem = gtk_menu_item_new ();

context = gtk_widget_get_style_context (GTK_WIDGET(icon_box));
@@ -244,6 +250,8 @@ panel_image_menu_item_new_from_gicon (GIcon *gicon,
g_settings_bind (icon_settings, "menus-have-icons", icon, "visible",
G_SETTINGS_BIND_GET);

g_free (concat);

return menuitem;
}

@@ -253,9 +261,9 @@ panel_check_menu_item_new (GtkWidget *widget_check)
GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
GtkWidget *menuitem = gtk_menu_item_new ();
GtkWidget *label_name = gtk_bin_get_child (GTK_BIN (widget_check));
gchar *concat = g_strconcat (gtk_label_get_label (GTK_LABEL (label_name)), " ", NULL);

gtk_label_set_text_with_mnemonic (GTK_LABEL (label_name),
g_strconcat (gtk_label_get_label (GTK_LABEL (label_name)), " ", NULL));
gtk_label_set_text_with_mnemonic (GTK_LABEL (label_name), concat);

gtk_widget_set_margin_start (widget_check, 2);
gtk_widget_set_margin_start (gtk_bin_get_child (GTK_BIN (widget_check)), 11);
@@ -266,5 +274,7 @@ panel_check_menu_item_new (GtkWidget *widget_check)

gtk_label_set_mnemonic_widget (GTK_LABEL (label_name), menuitem);

g_free (concat);

return menuitem;
}

0 comments on commit 9628efb

Please sign in to comment.
You can’t perform that action at this time.