]> git.eshelyaron.com Git - emacs.git/commitdiff
(x_connection_closed): Consolidate identical tests.
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 21 Feb 2008 16:51:07 +0000 (16:51 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Thu, 21 Feb 2008 16:51:07 +0000 (16:51 +0000)
(x_delete_terminal): Don't crash if called via x_connection_closed.

src/ChangeLog
src/xterm.c

index e1b8d8a5cefcc229492ef5645a754bbff31d8e4c..73e4f942a2edfb072375b48ea77aee862c26869e 100644 (file)
@@ -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>
 
index d9670fe4446a4647bfd08dcf0a63f977912db121..709be459b203bc9b17678091f7d10d03c6f41c90 100644 (file)
@@ -8103,25 +8103,23 @@ x_connection_closed (dpy, error_message)
      OpenWindows in certain situations.  I suspect that is a bug
      in OpenWindows.  I don't know how to circumvent it here.  */
 
-#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;
-    }
+#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.  */
+      {
+       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);
+      xg_display_close (dpyinfo->display);
 #endif
 
-  if (dpyinfo)
-    {
       /* Indicate that this display is dead.  */
       dpyinfo->display = 0;
 
@@ -11834,30 +11832,35 @@ x_delete_terminal (struct terminal *terminal)
     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
+      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);
-      }
+       /* 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);
+      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;