diff src/menu.c @ 1413:3bc4967aaa57

Use dynamic allocation for editor key passed to various callbacks.
author zas_
date Wed, 11 Mar 2009 17:38:20 +0000
parents 67573155210c
children b106af9689db
line wrap: on
line diff
--- a/src/menu.c	Tue Mar 10 22:52:12 2009 +0000
+++ b/src/menu.c	Wed Mar 11 17:38:20 2009 +0000
@@ -64,6 +64,10 @@
  * edit menu
  *-----------------------------------------------------------------------------
  */
+static void edit_item_destroy_cb(GtkWidget *widget, gpointer data)
+{
+	g_free(data);
+}
 
 static void add_edit_items(GtkWidget *menu, GCallback func, GList *fd_list)
 {
@@ -81,11 +85,15 @@
 
 		if (active)
 			{
+			GtkWidget *item;
 			const gchar *stock_id = NULL;
-			if (editor->icon && register_theme_icon_as_stock(editor->key, editor->icon))
-				stock_id = editor->key;
+			gchar *key = g_strdup(editor->key);
 
-			menu_item_add_stock(menu, editor->name, stock_id, func, editor->key);
+			if (editor->icon && register_theme_icon_as_stock(key, editor->icon))
+				stock_id = key;
+
+			item = menu_item_add_stock(menu, editor->name, stock_id, func, key);
+			g_signal_connect(G_OBJECT(item), "destroy", G_CALLBACK(edit_item_destroy_cb), key);
 			}
 		}