changeset 21405:7ea1f93cffe2

Don't leak all bar one of the closure structs allocated by pidgin_make_mini_dialog().
author Will Thompson <will.thompson@collabora.co.uk>
date Sun, 04 Nov 2007 23:56:25 +0000
parents 2e60aae8b9c5
children 7e07f5b271e5
files pidgin/gtkutils.c
diffstat 1 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkutils.c	Sun Nov 04 15:57:38 2007 +0000
+++ b/pidgin/gtkutils.c	Sun Nov 04 23:56:25 2007 +0000
@@ -2922,7 +2922,17 @@
 {
 	struct _old_button_clicked_cb_data *data = user_data;
 	data->cb(data->data, button);
-	g_free(data);
+}
+
+static void
+old_mini_dialog_destroy_cb(GtkWidget *dialog,
+                           GList *cb_datas)
+{
+	while (cb_datas != NULL)
+	{
+		g_free(cb_datas->data);
+		cb_datas = g_list_delete_link(cb_datas, cb_datas);
+	}
 }
 
 GtkWidget *
@@ -2935,6 +2945,7 @@
 {
 	PidginMiniDialog *mini_dialog;
 	const char *button_text;
+	GList *cb_datas = NULL;
 	va_list args;
 	static gboolean first_call = TRUE;
 
@@ -2960,9 +2971,13 @@
 		data->data = user_data;
 		pidgin_mini_dialog_add_button(mini_dialog, button_text,
 			old_mini_dialog_button_clicked_cb, data);
+		cb_datas = g_list_append(cb_datas, data);
 	}
 	va_end(args);
 
+	g_signal_connect(G_OBJECT(mini_dialog), "destroy",
+		G_CALLBACK(old_mini_dialog_destroy_cb), cb_datas);
+
 	return GTK_WIDGET(mini_dialog);
 }