emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r117845: * xterm.c (x_term_init): Consolidate duplic


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r117845: * xterm.c (x_term_init): Consolidate duplicated code.
Date: Tue, 09 Sep 2014 03:23:24 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117845
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Tue 2014-09-09 07:22:36 +0400
message:
  * xterm.c (x_term_init): Consolidate duplicated code.
  [USE_LUCID]: Revert 2014-04-02 change (Bug#18403).  Add comment.
  (x_delete_terminal): Do not close X connection fd (Bug#18403).
  Add eassert and mark dpyinfo as dead only if it was alive.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/xterm.c                    xterm.c-20091113204419-o5vbwnq5f7feedwu-244
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-09-08 06:00:58 +0000
+++ b/src/ChangeLog     2014-09-09 03:22:36 +0000
@@ -1,3 +1,10 @@
+2014-09-09  Dmitry Antipov  <address@hidden>
+
+       * xterm.c (x_term_init): Consolidate duplicated code.
+       [USE_LUCID]: Revert 2014-04-02 change (Bug#18403).  Add comment.
+       (x_delete_terminal): Do not close X connection fd (Bug#18403).
+       Add eassert and mark dpyinfo as dead only if it was alive.
+
 2014-09-08  Eli Zaretskii  <address@hidden>
 
        * dispnew.c (prepare_desired_row): When MODE_LINE_P is zero,

=== modified file 'src/xterm.c'
--- a/src/xterm.c       2014-09-04 05:38:37 +0000
+++ b/src/xterm.c       2014-09-09 03:22:36 +0000
@@ -10667,7 +10667,6 @@
 struct x_display_info *
 x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
 {
-  int connection;
   Display *dpy;
   struct terminal *terminal;
   struct x_display_info *dpyinfo;
@@ -11110,22 +11109,19 @@
 
   xsettings_initialize (dpyinfo);
 
-  connection = ConnectionNumber (dpyinfo->display);
-
   /* This is only needed for distinguishing keyboard and process input.  */
-  if (connection != 0)
-    add_keyboard_wait_descriptor (connection);
+  if (dpyinfo->connection != 0)
+    add_keyboard_wait_descriptor (dpyinfo->connection);
 
 #ifdef F_SETOWN
-  fcntl (connection, F_SETOWN, getpid ());
+  fcntl (dpyinfo->connection, F_SETOWN, getpid ());
 #endif /* ! defined (F_SETOWN) */
 
   if (interrupt_input)
-    init_sigio (connection);
+    init_sigio (dpyinfo->connection);
 
 #ifdef USE_LUCID
   {
-    XFontStruct *xfont = NULL;
     XrmValue d, fr, to;
     Font font;
 
@@ -11139,10 +11135,10 @@
     x_catch_errors (dpy);
     if (!XtCallConverter (dpy, XtCvtStringToFont, &d, 1, &fr, &to, NULL))
       emacs_abort ();
-    if (x_had_errors_p (dpy) || !((xfont = XQueryFont (dpy, font))))
+    if (x_had_errors_p (dpy) || !XQueryFont (dpy, font))
       XrmPutLineResource (&xrdb, "Emacs.dialog.*.font: 9x15");
-    if (xfont)
-      XFreeFont (dpy, xfont);
+    /* Do not free XFontStruct returned by the above call to XQueryFont.
+       This leads to X protocol errors at XtCloseDisplay (Bug#18403).  */
     x_uncatch_errors ();
   }
 #endif
@@ -11375,18 +11371,17 @@
       XCloseDisplay (dpyinfo->display);
 #endif
 #endif /* ! USE_GTK */
-    }
 
-  /* No more input on this descriptor.  */
-  if (0 <= dpyinfo->connection)
-    {
+      /* No more input on this descriptor.  Do not close it because
+        it's already closed by X(t)CloseDisplay (Bug#18403).  */
+      eassert (0 <= dpyinfo->connection);
       delete_keyboard_wait_descriptor (dpyinfo->connection);
-      emacs_close (dpyinfo->connection);
+
+      /* Mark as dead. */
+      dpyinfo->display = NULL;
+      dpyinfo->connection = -1;
     }
 
-  /* Mark as dead. */
-  dpyinfo->display = NULL;
-  dpyinfo->connection = -1;
   x_delete_display (dpyinfo);
   unblock_input ();
 }


reply via email to

[Prev in Thread] Current Thread [Next in Thread]