Emacsist RSS --- If never, make it ever: C-h C-h

"One XNOOP in 100 loops will make Emacs terminate"

7487

这里 查看更多 Emacs 相关推荐文章最新 Emacs 圈的动态. 欢迎关注微信公众账号: Emacsist

/* On some systems, an X bug causes Emacs to get no more events
   when the window is destroyed.  Detect that.  (1994.)  */
if (! event_found)
  {
    /* Emacs and the X Server eats up CPU time if XNoOp is done every time.
       One XNOOP in 100 loops will make Emacs terminate.
       B. Bretthauer, 1994 */
    x_noop_count++;
    if (x_noop_count >= 100)
      {
        x_noop_count=0;

        if (next_noop_dpyinfo == 0)
          next_noop_dpyinfo = x_display_list;

        XNoOp (next_noop_dpyinfo->display);

        /* Each time we get here, cycle through the displays now open.  */
        next_noop_dpyinfo = next_noop_dpyinfo->next;
      }
  }

I had some difficulties believing that an over 20 years old comment still holds true, so I snipped this functionality out for fun:

--- a/xterm.c       2016-06-05 11:38:14.471347194 +0200
+++ b/xterm.c       2016-06-05 11:36:37.398817889 +0200
@@ -8786,26 +8786,10 @@ XTread_socket (struct terminal *terminal
     }
 #endif /* USE_GTK */

-  /* On some systems, an X bug causes Emacs to get no more events
-     when the window is destroyed.  Detect that.  (1994.)  */
   if (! event_found)
     {
-      /* Emacs and the X Server eats up CPU time if XNoOp is done every time.
-    One XNOOP in 100 loops will make Emacs terminate.
-    B. Bretthauer, 1994 */
       x_noop_count++;
-      if (x_noop_count >= 100)
-   {
-     x_noop_count=0;
-
-     if (next_noop_dpyinfo == 0)
-       next_noop_dpyinfo = x_display_list;
-
-     XNoOp (next_noop_dpyinfo->display);
-
-     /* Each time we get here, cycle through the displays now open.  */
-     next_noop_dpyinfo = next_noop_dpyinfo->next;
-   }
+      fprintf(stderr, "XNoOp %d occurred\n", x_noop_count);
     }

   /* If the focus was just given to an auto-raising frame,

No difference when used on a GTK or Lucid build. Other than nearly every event causing the diagnostic message to print…

原文出处: Vasilij Schneidermann
原文地址: http://emacshorrors.com/posts/one-xnoop-in-loops-will-make-emacs-terminate.html
原文时间: 2016-06-05 17:50
本文地址: http://emacsist.com/10877
整理时间: 2016-06-05 21:51

本文由 Hick 整理,转载请保留以上信息;
COPYLEFTThe articles on this site come from Internet, thanks to all the original authors.
      If anything about COPYRIGHT, or LEFT, please contact Emacsist at gmail dot com .