changeset 1381:94eb664a7da1

do not crash if an exif entry is deleted during editing
author nadvornik
date Thu, 05 Mar 2009 23:32:56 +0000
parents ddb9c10ee9c6
children 31a747f9d268
files src/bar_exif.c
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/bar_exif.c	Thu Mar 05 23:02:15 2009 +0000
+++ b/src/bar_exif.c	Thu Mar 05 23:32:56 2009 +0000
@@ -73,6 +73,7 @@
 	GtkWidget *widget; /* pane or entry, devidet by presenceof "pane_data" or "entry_data" */
 
 	/* dialog parts */
+	GenericDialog *gd;
 	GtkWidget *key_entry;
 	GtkWidget *title_entry;
 	gboolean if_set;
@@ -354,10 +355,16 @@
 			 G_CALLBACK(bar_pane_exif_dnd_receive), NULL);
 }
 
+static void bar_pane_exif_edit_close_cb(GtkWidget *widget, gpointer data)
+{
+	GenericDialog *gd = data;
+	generic_dialog_close(gd);
+}
 
 static void bar_pane_exif_edit_destroy_cb(GtkWidget *widget, gpointer data)
 {
 	ConfDialogData *cdd = data;
+	g_signal_handlers_disconnect_by_func(cdd->widget, G_CALLBACK(bar_pane_exif_edit_close_cb), cdd->gd);
 	g_free(cdd);
 }
 
@@ -365,6 +372,7 @@
 {
 }
 
+
 static void bar_pane_exif_edit_ok_cb(GenericDialog *gd, gpointer data)
 {
 	ConfDialogData *cdd = data;
@@ -427,12 +435,16 @@
 
 	cdd->if_set = ee ? ee->if_set : TRUE;
 
-	gd = generic_dialog_new(ee ? _("Configure entry") : _("Add entry"), "exif_entry_edit",
+	cdd->gd = gd = generic_dialog_new(ee ? _("Configure entry") : _("Add entry"), "exif_entry_edit",
 				widget, TRUE,
 				bar_pane_exif_edit_cancel_cb, cdd);
 	g_signal_connect(G_OBJECT(gd->dialog), "destroy",
 			 G_CALLBACK(bar_pane_exif_edit_destroy_cb), cdd);
 
+	/* in case the entry is deleted during editing */
+	g_signal_connect(G_OBJECT(widget), "destroy",
+			 G_CALLBACK(bar_pane_exif_edit_close_cb), gd);
+
 	generic_dialog_add_message(gd, NULL, ee ? _("Configure entry") : _("Add entry"), NULL);
 
 	generic_dialog_add_button(gd, GTK_STOCK_OK, NULL,