# HG changeset patch # User Stefan Monnier # Date 1203612667 0 # Node ID 3a7d2adfb2af6d740f33cf1ece338dabd5b0f75e # Parent af7423454309797358b562f8082e1e58a1e83290 (x_connection_closed): Consolidate identical tests. (x_delete_terminal): Don't crash if called via x_connection_closed. diff -r af7423454309 -r 3a7d2adfb2af src/ChangeLog --- a/src/ChangeLog Thu Feb 21 15:27:15 2008 +0000 +++ b/src/ChangeLog Thu Feb 21 16:51:07 2008 +0000 @@ -1,7 +1,12 @@ +2008-02-21 Stefan Monnier + + * xterm.c (x_connection_closed): Consolidate identical tests. + (x_delete_terminal): Don't crash if called via x_connection_closed. + 2008-02-21 Kenichi Handa * xdisp.c (decode_mode_spec): New arg string. - (display_mode_element): Adjusted for the above change. + (display_mode_element): Adjust for the above change. 2008-02-19 Stefan Monnier diff -r af7423454309 -r 3a7d2adfb2af src/xterm.c --- a/src/xterm.c Thu Feb 21 15:27:15 2008 +0000 +++ b/src/xterm.c Thu Feb 21 16:51:07 2008 +0000 @@ -8103,25 +8103,23 @@ OpenWindows in certain situations. I suspect that is a bug in OpenWindows. I don't know how to circumvent it here. */ + if (dpyinfo) + { #ifdef USE_X_TOOLKIT - /* If DPYINFO is null, this means we didn't open the display - in the first place, so don't try to close it. */ - if (dpyinfo) - { - extern void (*fatal_error_signal_hook) P_ ((void)); - fatal_error_signal_hook = x_fatal_error_signal; - XtCloseDisplay (dpy); - fatal_error_signal_hook = NULL; - } + /* If DPYINFO is null, this means we didn't open the display + in the first place, so don't try to close it. */ + { + extern void (*fatal_error_signal_hook) P_ ((void)); + fatal_error_signal_hook = x_fatal_error_signal; + XtCloseDisplay (dpy); + fatal_error_signal_hook = NULL; + } #endif #ifdef USE_GTK - if (dpyinfo) - xg_display_close (dpyinfo->display); -#endif - - if (dpyinfo) - { + xg_display_close (dpyinfo->display); +#endif + /* Indicate that this display is dead. */ dpyinfo->display = 0; @@ -11834,30 +11832,35 @@ return; BLOCK_INPUT; + /* If called from x_connection_closed, the display may already be closed + and dpyinfo->display was set to 0 to indicate that. */ + if (dpyinfo->display) + { #ifdef USE_FONT_BACKEND - if (enable_font_backend) - XFreeFont (dpyinfo->display, dpyinfo->font); - else -#endif - /* Free the fonts in the font table. */ - for (i = 0; i < dpyinfo->n_fonts; i++) - if (dpyinfo->font_table[i].name) - { - XFreeFont (dpyinfo->display, dpyinfo->font_table[i].font); - } - - x_destroy_all_bitmaps (dpyinfo); - XSetCloseDownMode (dpyinfo->display, DestroyAll); + if (enable_font_backend) + XFreeFont (dpyinfo->display, dpyinfo->font); + else +#endif + /* Free the fonts in the font table. */ + for (i = 0; i < dpyinfo->n_fonts; i++) + if (dpyinfo->font_table[i].name) + { + XFreeFont (dpyinfo->display, dpyinfo->font_table[i].font); + } + + x_destroy_all_bitmaps (dpyinfo); + XSetCloseDownMode (dpyinfo->display, DestroyAll); #ifdef USE_GTK - xg_display_close (dpyinfo->display); + xg_display_close (dpyinfo->display); #else #ifdef USE_X_TOOLKIT - XtCloseDisplay (dpyinfo->display); + XtCloseDisplay (dpyinfo->display); #else - XCloseDisplay (dpyinfo->display); + XCloseDisplay (dpyinfo->display); #endif #endif /* ! USE_GTK */ + } x_delete_display (dpyinfo); UNBLOCK_INPUT;