diff options
author | Guy Harris <guy@alum.mit.edu> | 2000-04-01 11:30:53 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2000-04-01 11:30:53 +0000 |
commit | 5549f62efd72450189dad088a7206ed4b6a1bfb6 (patch) | |
tree | ac10eb58af1e11a0ef59b3ade4e015bf2462734c /gtk | |
parent | 4173af0077958ed2559a7cfff39a5c39c1c3f1a9 (diff) | |
download | wireshark-5549f62efd72450189dad088a7206ed4b6a1bfb6.tar.gz wireshark-5549f62efd72450189dad088a7206ed4b6a1bfb6.tar.bz2 wireshark-5549f62efd72450189dad088a7206ed4b6a1bfb6.zip |
There's no need to catch the "delete_event" signal on "Follow TCP
Stream" windows - the window should always be deleted in that situation,
so there's no need for a signal handler that might return TRUE (meaning
"don't delete the window"), and the "destroy" handler gets called when
the window actually gets destroyed, so there's no need to do any cleanup
in the "delete_event" handler.
Catch the "delete_event" signal on the main window in a routine with the
right signature, and that returns FALSE so that the window actually gets
deleted.
Call "close_cap_file()" in the callback for the "File:Quit" menu item
(which is also called by the "delete_event" handler for the main
window), rather than calling it after "gtk_main()" returns -
"close_cap_file()" manipulates stuff in the main window, and if we do so
after "gtk_main()" returns, it appears that the main window may have
disappeared (if we are exiting because the user deleted the main
window), in which case we can get crashes or other errors when
"close_cap_file()" tries to manipulate stuff in the main window.
There's no need to catch the "destroy" signal on the main window - we do
some of the cleanup in the handler for "delete_event" (we have to, for
reasons described above), and we do the rest of it after the main
routine returns.
svn path=/trunk/; revision=1773
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/main.c | 57 |
1 files changed, 44 insertions, 13 deletions
diff --git a/gtk/main.c b/gtk/main.c index 8e850738bc..99ea24f348 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1,6 +1,6 @@ /* main.c * - * $Id: main.c,v 1.110 2000/04/01 10:23:01 guy Exp $ + * $Id: main.c,v 1.111 2000/04/01 11:30:53 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -216,8 +216,6 @@ follow_stream_cb( GtkWidget *w, gpointer data ) { streamwindow = gtk_window_new( GTK_WINDOW_TOPLEVEL); gtk_widget_set_name( streamwindow, "TCP stream window" ); - gtk_signal_connect( GTK_OBJECT(streamwindow), "delete_event", - GTK_SIGNAL_FUNC(follow_destroy_cb), NULL); gtk_signal_connect( GTK_OBJECT(streamwindow), "destroy", GTK_SIGNAL_FUNC(follow_destroy_cb), NULL); @@ -1021,9 +1019,50 @@ set_ptree_expander_style_all(gint style) set_ptree_expander_style_packet_wins(style); } +static gboolean +main_window_delete_event_cb(GtkWidget *widget, GdkEvent *event, gpointer data) +{ + file_quit_cmd_cb(widget, data); + + /* Say that the window should be deleted. */ + return FALSE; +} + void file_quit_cmd_cb (GtkWidget *widget, gpointer data) { + /* XXX - should we check whether the capture file is an + unsaved temporary file for a live capture and, if so, + pop up a "do you want to exit without saving the capture + file?" dialog, and then just return, leaving said dialog + box to forcibly quit if the user clicks "OK"? + + If so, note that this should be done in a subroutine that + returns TRUE if we do so, and FALSE otherwise, and that + "main_window_delete_event_cb()" should return its + return value. */ + + /* Close any capture file we have open; on some OSes, you can't + unlink a temporary capture file if you have it open. + "close_cap_file()" will unlink it after closing it if + it's a temporary file. + + We do this here, rather than after the main loop returns, + as, after the main loop returns, the main window may have + been destroyed (if this is called due to a "destroy" + even on the main window rather than due to the user + selecting a menu item), and there may be a crash + or other problem when "close_cap_file()" tries to + clean up stuff in the main window. + + XXX - is there a better place to put this? + Or should we have a routine that *just* closes the + capture file, and doesn't do anything with the UI, + which we'd call here, and another routine that + calls that routine and also cleans up the UI, which + we'd call elsewhere? */ + close_cap_file(&cf, info_bar); + /* Exit by leaving the main loop, so that any quit functions we registered get called. */ gtk_main_quit(); @@ -1523,12 +1562,6 @@ main(int argc, char *argv[]) gtk_main(); - /* Close any capture file we have open; on some OSes, you can't - unlink a temporary capture file if you have it open. - "close_cap_file()" will unlink it after closing it if - it's a temporary file. */ - close_cap_file(&cf, info_bar); - ethereal_proto_cleanup(); g_free(rc_file); @@ -1557,10 +1590,8 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs) /* Main window */ top_level = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_set_name(top_level, "main window"); - gtk_signal_connect(GTK_OBJECT(top_level), "delete_event", - GTK_SIGNAL_FUNC(file_quit_cmd_cb), "WM destroy"); - gtk_signal_connect(GTK_OBJECT(top_level), "destroy", - GTK_SIGNAL_FUNC(file_quit_cmd_cb), "WM destroy"); + gtk_signal_connect(GTK_OBJECT(top_level), "delete_event", + GTK_SIGNAL_FUNC(main_window_delete_event_cb), NULL); gtk_window_set_title(GTK_WINDOW(top_level), "The Ethereal Network Analyzer"); gtk_widget_set_usize(GTK_WIDGET(top_level), DEF_WIDTH, -1); gtk_window_set_policy(GTK_WINDOW(top_level), TRUE, TRUE, FALSE); |