changeset 18778:38bac267bf8e

Clean up the font and insert menus when the imhtmltoolbar is disposed of. This fixes a leak (and the crash in #2385). Fixes #2385.
author Daniel Atallah <daniel.atallah@gmail.com>
date Thu, 02 Aug 2007 15:40:19 +0000
parents ee655cba03ca
children f6656fd1d2d5
files pidgin/gtkimhtmltoolbar.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkimhtmltoolbar.c	Thu Aug 02 14:23:24 2007 +0000
+++ b/pidgin/gtkimhtmltoolbar.c	Thu Aug 02 15:40:19 2007 +0000
@@ -961,6 +961,7 @@
 gtk_imhtmltoolbar_finalize (GObject *object)
 {
 	GtkIMHtmlToolbar *toolbar = GTK_IMHTMLTOOLBAR(object);
+	GtkWidget *menu;
 
 	if (toolbar->image_dialog != NULL)
 	{
@@ -985,6 +986,13 @@
 	free(toolbar->sml);
 	gtk_object_sink(GTK_OBJECT(toolbar->tooltips));
 
+	menu = g_object_get_data(object, "font_menu");
+	if (menu)
+		gtk_widget_destroy(menu);
+	menu = g_object_get_data(object, "insert_menu");
+	if (menu)
+		gtk_widget_destroy(menu);
+
 	G_OBJECT_CLASS(parent_class)->finalize (object);
 }
 
@@ -1146,8 +1154,8 @@
 	gtk_widget_show_all(font_button);
 
 	font_menu = gtk_menu_new();
+	g_object_set_data(G_OBJECT(toolbar), "font_menu", font_menu);
 
-	
 	for (i = 0; buttons[i].label; i++) {
 		GtkWidget *old = *buttons[i].button;
 		menuitem = gtk_check_menu_item_new_with_mnemonic(buttons[i].label);
@@ -1201,6 +1209,7 @@
 	gtk_widget_show_all(insert_button);
 
 	insert_menu = gtk_menu_new();
+	g_object_set_data(G_OBJECT(toolbar), "insert_menu", insert_menu);
 
 	menuitem = gtk_menu_item_new_with_mnemonic(_("_Smiley"));
 	g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(gtk_button_clicked), toolbar->smiley);