Wireshark-bugs: [Wireshark-bugs] [Bug 9129] Crash then try to delete the same entry (length rang

Date: Fri, 04 Oct 2013 12:59:47 +0000

changed bug 9129

What Removed Added
Attachment #11594 Flags review_for_checkin? review_for_checkin+

Comment # 4 on bug 9129 from
Comment on attachment 11594 [details]
only allow one popup for confirming deletion

>diff --git a/ui/gtk/uat_gui.c b/ui/gtk/uat_gui.c
>index 038a5eb..590ce06 100644
>--- a/ui/gtk/uat_gui.c
>+++ b/ui/gtk/uat_gui.c
>@@ -114,6 +114,7 @@ struct _uat_dlg_data {
> 	GPtrArray *tobe_freed;
> };
> 
>+struct _uat_del *current_ud  = NULL;
> 
> static gboolean unsaved_dialog(GtkWindow *w, GdkEvent *e, gpointer u);
> static gboolean uat_window_delete_event_cb(GtkWindow *w, GdkEvent *e, gpointer u);
>@@ -549,39 +550,43 @@ struct _uat_del {
> 	gint	   idx;
> };
> 
>-static void uat_del_cb(GtkButton *button _U_, gpointer u) {
>-	struct _uat_del *ud = (struct _uat_del *)u;
>+static void uat_del_cb(GtkButton *button _U_, gpointer u _U_) {
> 	GtkTreeIter	 iter;
> 	GtkTreePath	*path;
> 
>-	uat_remove_record_idx(ud->uat, ud->idx);
>+	g_assert(current_ud);
> 
>-	if (ud->uat->rep) {
>-		path = gtk_tree_path_new_from_indices(ud->idx, -1);
>-		if (path && gtk_tree_model_get_iter(GTK_TREE_MODEL(ud->uat->rep->list_store), &iter, path)) {
>-			gtk_list_store_remove(ud->uat->rep->list_store, &iter);
>+	uat_remove_record_idx(current_ud->uat, current_ud->idx);
>+
>+	if (current_ud->uat->rep) {
>+		path = gtk_tree_path_new_from_indices(current_ud->idx, -1);
>+		if (path && gtk_tree_model_get_iter(GTK_TREE_MODEL(current_ud->uat->rep->list_store), &iter, path)) {
>+			gtk_list_store_remove(current_ud->uat->rep->list_store, &iter);
> 		}
> 	}
> 
>-	ud->uat->changed = TRUE;
>-	set_buttons(ud->uat, -1);
>+	current_ud->uat->changed = TRUE;
>+	set_buttons(current_ud->uat, -1);
> 
>-	window_destroy(GTK_WIDGET(ud->win));
>+	window_destroy(GTK_WIDGET(current_ud->win));
> 
>-	if (ud->uat->rep)
>-		window_present(GTK_WIDGET(ud->uat->rep->window));
>+	if (current_ud->uat->rep)
>+		window_present(GTK_WIDGET(current_ud->uat->rep->window));
> 
>-	g_free(ud);
>+	g_free(current_ud);
>+   current_ud = NULL;
> }
> 
>-static void uat_cancel_del_cb(GtkButton *button _U_, gpointer u) {
>-	struct _uat_del *ud = (struct _uat_del *)u;
>+static void uat_cancel_del_cb(GtkButton *button _U_, gpointer u _U_) {
>+
>+	g_assert(current_ud);
> 
>-	window_destroy(GTK_WIDGET(ud->win));
>+	window_destroy(GTK_WIDGET(current_ud->win));
> 
>-	if (ud->uat->rep)
>-		window_present(GTK_WIDGET(ud->uat->rep->window));
>-	g_free(ud);
>+	if (current_ud->uat->rep)
>+		window_present(GTK_WIDGET(current_ud->uat->rep->window));
>+	g_free(current_ud);
>+   current_ud = NULL;
> }
> 
> static void uat_del_dlg(uat_t *uat, int idx) {
>@@ -589,11 +594,17 @@ static void uat_del_dlg(uat_t *uat, int idx) {
> 	uat_field_t	*f   = uat->fields;
> 	guint		 colnum;
> 	void		*rec = UAT_INDEX_PTR(uat, idx);
>-	struct _uat_del *ud  = (struct _uat_del *)g_malloc(sizeof(struct _uat_del));
> 
>-	ud->uat = uat;
>-	ud->idx = idx;
>-	ud->win = win = dlg_conf_window_new(ep_strdup_printf("%s: Confirm Delete", uat->name));
>+	/* we can only ever display one "confirm deletion" dialogue
>+	   at the same time */
>+	if (current_ud) {
>+		window_destroy(GTK_WIDGET(current_ud->win));
>+		g_free(current_ud);
>+	}
>+	current_ud  = (struct _uat_del *)g_malloc(sizeof(struct _uat_del));
>+	current_ud->uat = uat;
>+	current_ud->idx = idx;
>+	current_ud->win = win = dlg_conf_window_new(ep_strdup_printf("%s: Confirm Delete", uat->name));
> 
> 	gtk_window_set_resizable(GTK_WINDOW(win), FALSE);
> 	gtk_window_resize(GTK_WINDOW(win), 400, 25*(uat->ncols+2));
>@@ -624,10 +635,10 @@ static void uat_del_dlg(uat_t *uat, int idx) {
> 	gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
> 
> 	bt_ok = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_DELETE);
>-	g_signal_connect(bt_ok, "clicked", G_CALLBACK(uat_del_cb), ud);
>+	g_signal_connect(bt_ok, "clicked", G_CALLBACK(uat_del_cb), NULL);
> 
> 	bt_cancel = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
>-	g_signal_connect(bt_cancel, "clicked", G_CALLBACK(uat_cancel_del_cb), ud);
>+	g_signal_connect(bt_cancel, "clicked", G_CALLBACK(uat_cancel_del_cb), NULL);
> 	window_set_cancel_button( win, bt_cancel, NULL);
> 
> 	gtk_widget_show_all(win);


You are receiving this mail because:
  • You are watching all bug changes.