Fixed the problem with an assert coming from gtkwidget.c:3196 when
selecting a field from more than one protocol tree. It turns out that gtktree.c doesn't clear the tree-item selection list when you use gtk_tree_clear_items() (which calls gtk_tree_remove_items() ). So the next time a tree item is selected in a new protocol tree (which is our old protocol tree, with everything removed, and new things added), gtk_tree tries to _deselect_ our old selection. But that tree-item which is trying to be deselected is long gone, resulting in the assert because widget == NULL. A function needs to be added to gtk_tree to deselect the tree-item selection for us. (or we need to go through the hassle of creating a new gtk_tree instead of recycling tree_view over and over). I stole some code from another section of gtktree.c which lets us clear the selection in clear_tree_and_hex_views(). Also, I modified the argument to gtk_tree_set_view_mode. We were using "TRUE", when really we should have used a member of the GtkTreeViewMode enumeration, namely GTK_TREE_VIEW_ITEM ( which is 1, which is TRUE :-) svn path=/trunk/; revision=496
This commit is contained in:
parent
8f0acf3551
commit
77e429e1b9
10
ethereal.c
10
ethereal.c
@ -1,6 +1,6 @@
|
||||
/* ethereal.c
|
||||
*
|
||||
* $Id: ethereal.c,v 1.88 1999/08/15 06:59:02 guy Exp $
|
||||
* $Id: ethereal.c,v 1.89 1999/08/15 07:28:22 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
@ -818,7 +818,6 @@ print_fs_ok_cb(GtkWidget *w, gpointer data)
|
||||
static void
|
||||
print_fs_cancel_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
|
||||
gtk_widget_destroy(GTK_WIDGET(data));
|
||||
}
|
||||
|
||||
@ -934,7 +933,7 @@ packet_list_unselect_cb(GtkWidget *w, gint row, gint col, gpointer evt) {
|
||||
}
|
||||
|
||||
void
|
||||
tree_view_cb(GtkWidget *w) {
|
||||
tree_view_cb(GtkWidget *w, gpointer data) {
|
||||
|
||||
tree_selected_start = -1;
|
||||
tree_selected_len = -1;
|
||||
@ -1327,8 +1326,11 @@ main(int argc, char *argv[])
|
||||
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tv_scrollw),
|
||||
tree_view);
|
||||
gtk_tree_set_selection_mode(GTK_TREE(tree_view), GTK_SELECTION_SINGLE);
|
||||
|
||||
/* XXX - what's the difference between the next two lines? */
|
||||
gtk_tree_set_view_lines(GTK_TREE(tree_view), FALSE);
|
||||
gtk_tree_set_view_mode(GTK_TREE(tree_view), TRUE);
|
||||
gtk_tree_set_view_mode(GTK_TREE(tree_view), GTK_TREE_VIEW_ITEM);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(tree_view), "selection_changed",
|
||||
GTK_SIGNAL_FUNC(tree_view_cb), NULL);
|
||||
gtk_widget_show(tree_view);
|
||||
|
26
file.c
26
file.c
@ -1,7 +1,7 @@
|
||||
/* file.c
|
||||
* File I/O routines
|
||||
*
|
||||
* $Id: file.c,v 1.71 1999/08/15 06:59:03 guy Exp $
|
||||
* $Id: file.c,v 1.72 1999/08/15 07:28:23 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
@ -768,6 +768,9 @@ change_time_formats(capture_file *cf)
|
||||
static void
|
||||
clear_tree_and_hex_views(void)
|
||||
{
|
||||
GList *selection;
|
||||
GtkWidget *tmp_item;
|
||||
|
||||
/* Clear the hex dump. */
|
||||
gtk_text_freeze(GTK_TEXT(byte_view));
|
||||
gtk_text_set_point(GTK_TEXT(byte_view), 0);
|
||||
@ -775,11 +778,26 @@ clear_tree_and_hex_views(void)
|
||||
gtk_text_get_length(GTK_TEXT(byte_view)));
|
||||
gtk_text_thaw(GTK_TEXT(byte_view));
|
||||
|
||||
/* Clear the protocol tree view. */
|
||||
gtk_tree_clear_items(GTK_TREE(tree_view), 0,
|
||||
g_list_length(GTK_TREE(tree_view)->children));
|
||||
/* Deselect any selected tree item. gtktree.c should
|
||||
* do this when we clear_items, but it doesn't. I copied
|
||||
* this while() loop from gtktree.c, gtk_real_tree_select_child()
|
||||
*/
|
||||
selection = GTK_TREE(tree_view)->root_tree->selection;
|
||||
while (selection) {
|
||||
tmp_item = selection->data;
|
||||
gtk_tree_item_deselect(GTK_TREE_ITEM(tmp_item));
|
||||
gtk_widget_unref(tmp_item);
|
||||
selection = selection->next;
|
||||
}
|
||||
g_list_free(GTK_TREE(tree_view)->root_tree->selection);
|
||||
GTK_TREE(tree_view)->root_tree->selection = NULL;
|
||||
|
||||
/* Clear the protocol tree view. The length arg of -1
|
||||
* means to clear all items up to the end. */
|
||||
gtk_tree_clear_items(GTK_TREE(tree_view), 0, -1);
|
||||
}
|
||||
|
||||
|
||||
/* Select the packet on a given row. */
|
||||
void
|
||||
select_packet(capture_file *cf, int row)
|
||||
|
Loading…
x
Reference in New Issue
Block a user