im.pidgin.pidgin: 61d876a57f30f4e29a91a8411d259e8aaa4355ea

resiak at soc.pidgin.im resiak at soc.pidgin.im
Thu Nov 15 08:00:47 EST 2007


-----------------------------------------------------------------
Revision: 61d876a57f30f4e29a91a8411d259e8aaa4355ea
Ancestor: 2fbd093c6acc18376722869650f7568fa6af9fc8
Author: resiak at soc.pidgin.im
Date: 2007-11-15T12:30:51
Branch: im.pidgin.pidgin

Modified files:
        pidgin/minidialog.c

ChangeLog: 

Don't crash when someone ignores an error.  The mini-dialog was being
gtk_widget_destroy()ed twice.

-------------- next part --------------
============================================================
--- pidgin/minidialog.c	9c7606ed7a710a65f9c0986c9d7280e3f26e5bc6
+++ pidgin/minidialog.c	4509015cc777560bfb5547871d2e1373a53adc1c
@@ -53,6 +53,8 @@ typedef struct _PidginMiniDialogPrivate
 	GtkLabel *title;
 	GtkLabel *desc;
 	GtkBox *buttons;
+
+	guint idle_destroy_cb_id;
 } PidginMiniDialogPrivate;
 
 #define PIDGIN_MINI_DIALOG_GET_PRIVATE(dialog) \
@@ -118,10 +120,18 @@ mini_dialog_button_clicked_cb(GtkButton 
                               gpointer user_data)
 {
 	struct _mini_dialog_button_clicked_cb_data *data = user_data;
+	PidginMiniDialogPrivate *priv =
+		PIDGIN_MINI_DIALOG_GET_PRIVATE(data->mini_dialog);
 
+	/* Set up the destruction callback before calling the clicked callback,
+	 * so that if the mini-dialog gets destroyed during the clicked callback
+	 * the idle_destroy_cb is correctly removed by _finalize.
+	 */
+	priv->idle_destroy_cb_id =
+		g_idle_add((GSourceFunc) idle_destroy_cb, data->mini_dialog);
+
 	data->callback(data->mini_dialog, button, data->user_data);
 
-	g_idle_add((GSourceFunc) idle_destroy_cb, data->mini_dialog);
 }
 
 static void
@@ -272,6 +282,9 @@ pidgin_mini_dialog_finalize(GObject *obj
 	PidginMiniDialog *self = PIDGIN_MINI_DIALOG(object);
 	PidginMiniDialogPrivate *priv = PIDGIN_MINI_DIALOG_GET_PRIVATE(self);
 
+	if (priv->idle_destroy_cb_id)
+		g_source_remove(priv->idle_destroy_cb_id);
+
 	g_free(priv);
 	self->priv = NULL;
 


More information about the Commits mailing list