emacs-diffs
[Top][All Lists]
Advanced

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

master bd44f39d6d 04/14: Restart tick counting every command


From: Eli Zaretskii
Subject: master bd44f39d6d 04/14: Restart tick counting every command
Date: Fri, 24 Jun 2022 03:54:18 -0400 (EDT)

branch: master
commit bd44f39d6d4900e406f87d6f4df1ee015dd21300
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Restart tick counting every command
    
    * src/keyboard.c (command_loop_1): Reinitialize the tick count
    before executing each command in the loop.
    * src/xdisp.c (update_redisplay_ticks): Be more defensive to W
    being NULL and to its buffer being nil.  Set
    'windows_or_buffers_changed' to avoid trusting stale window data
    like w->window_end_valid.
---
 src/keyboard.c |  5 +++++
 src/xdisp.c    | 26 ++++++++++++++++++++------
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/src/keyboard.c b/src/keyboard.c
index 55d710ed62..7d7dd2dba0 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1501,6 +1501,11 @@ command_loop_1 (void)
             point_before_last_command_or_undo = PT;
             buffer_before_last_command_or_undo = current_buffer;
 
+           /* Restart our counting of redisplay ticks before
+              executing the command, so that we don't blame the new
+              command for the sins of the previous one.  */
+           update_redisplay_ticks (0, NULL);
+
             call1 (Qcommand_execute, Vthis_command);
 
 #ifdef HAVE_WINDOW_SYSTEM
diff --git a/src/xdisp.c b/src/xdisp.c
index 27041cb162..ae428f4b40 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -17176,7 +17176,10 @@ redisplay_window_1 (Lisp_Object window)
    redisplay of the window takes "too long".
 
    TICKS is the amount of ticks to add to the W's current count; zero
-   means to initialize the count to zero.  */
+   means to initialize the tick count to zero.
+
+   W can be NULL if TICKS is zero: that means unconditionally
+   re-initialize the current tick count to zero.   */
 void
 update_redisplay_ticks (int ticks, struct window *w)
 {
@@ -17184,9 +17187,9 @@ update_redisplay_ticks (int ticks, struct window *w)
   static struct window *cwindow;
   static EMACS_INT window_ticks;
 
-  /* We only initialize the count if this is a different window.
-     Otherwise, this is a call from init_iterator for the same window
-     we tracked before, and we should keep the count.  */
+  /* We only initialize the count if this is a different window or
+     NULL.  Otherwise, this is a call from init_iterator for the same
+     window we tracked before, and we should keep the count.  */
   if (!ticks && w != cwindow)
     {
       cwindow = w;
@@ -17195,8 +17198,19 @@ update_redisplay_ticks (int ticks, struct window *w)
   if (ticks > 0)
     window_ticks += ticks;
   if (max_redisplay_ticks > 0 && window_ticks > max_redisplay_ticks)
-    error ("Window showing buffer %s takes too long to redisplay",
-          SSDATA (BVAR (XBUFFER (w->contents), name)));
+    {
+      /* In addition to a buffer, this could be a window (for non-leaf
+        windows, not expected here) or nil (for pseudo-windows like
+        the one used for the native tool bar).  */
+      Lisp_Object contents = w ? w->contents : Qnil;
+      char *bufname =
+       BUFFERP (contents)
+       ? SSDATA (BVAR (XBUFFER (contents), name))
+       : (char *) "<none>";
+
+      windows_or_buffers_changed = 177;
+      error ("Window showing buffer %s takes too long to redisplay", bufname);
+    }
 }
 
 



reply via email to

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