From c39b3330725220342d47d75514cc7c07355da4f1 Mon Sep 17 00:00:00 2001 From: Luis Ontanon Date: Wed, 15 Mar 2006 01:41:39 +0000 Subject: Fix bug 710 and avoid having it crash when more than one instance are open at once. I think that whoever wrote the whole stats_tree thing should rewrite it ASAP, because it sucks! I did ?!?!?? ooops! svn path=/trunk/; revision=17627 --- gtk/stats_tree_stat.c | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'gtk/stats_tree_stat.c') diff --git a/gtk/stats_tree_stat.c b/gtk/stats_tree_stat.c index b25da931ca..8840208701 100644 --- a/gtk/stats_tree_stat.c +++ b/gtk/stats_tree_stat.c @@ -190,17 +190,39 @@ static void free_gtk_tree(GtkWindow *win _U_, stats_tree *st) st->root.pr->iter = NULL; #endif + st->cfg->in_use = FALSE; stats_tree_free(st); } +static void clear_node_pr(stat_node* n) { + stat_node* c; + for (c = n->children; c; c = c->next) { + clear_node_pr(c); + } + +#if GTK_MAJOR_VERSION >= 2 + if (n->pr->iter) { + gtk_tree_store_remove(n->st->pr->store, n->pr->iter); + n->pr->iter = NULL; + } +#else + if (n->pr->node) { + gtk_ctree_remove_node(n->st->pr->ctree,n->pr->node); + n->pr->node = NULL; + } +#endif + +} + static void reset_tap(void* p) { stats_tree* st = p; - - if (st->start > -1.0) { - remove_tap_listener(st); - } - + stat_node* c; + for (c = st->root.children; c; c = c->next) { + clear_node_pr(c); + } + + st->cfg->init(st); } /* initializes the stats_tree window */ @@ -231,6 +253,12 @@ static void init_gtk_tree(const char* optarg, void *userdata _U_) { if (abbr) { cfg = stats_tree_get_cfg_by_abbr(abbr); + if (cfg->in_use) { + /* XXX: ! */ + report_failure("cannot open more than one tree of the same type at once"); + return; + } + if (cfg != NULL) { init_strlen = strlen(cfg->pr->stat_dlg->init_string); @@ -257,6 +285,8 @@ static void init_gtk_tree(const char* optarg, void *userdata _U_) { return; } + cfg->in_use = TRUE; + window_name = g_strdup_printf("%s Stats Tree", cfg->name); st->pr->win = window_new_with_geom(GTK_WINDOW_TOPLEVEL,window_name,window_name); @@ -370,8 +400,6 @@ static void init_gtk_tree(const char* optarg, void *userdata _U_) { gtk_tree_view_set_model(GTK_TREE_VIEW(st->pr->tree),GTK_TREE_MODEL(st->pr->store)); #endif - st->cfg->init(st); - cf_retap_packets(&cfile, FALSE); } -- cgit v1.2.1