changeset 92052:3a7d2adfb2af

(x_connection_closed): Consolidate identical tests. (x_delete_terminal): Don't crash if called via x_connection_closed.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 21 Feb 2008 16:51:07 +0000
parents af7423454309
children bd92ee83d7ae
files src/ChangeLog src/xterm.c
diffstat 2 files changed, 40 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- 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  <monnier@iro.umontreal.ca>
+
+	* 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  <handa@ni.aist.go.jp>
 
 	* 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  <monnier@iro.umontreal.ca>
 
--- 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;