]> git.eshelyaron.com Git - emacs.git/commitdiff
Prevent crashes due to redisplay while realizing the default face
authorEli Zaretskii <eliz@gnu.org>
Sun, 26 May 2024 16:41:30 +0000 (19:41 +0300)
committerEshel Yaron <me@eshelyaron.com>
Mon, 27 May 2024 20:26:58 +0000 (22:26 +0200)
* src/xfaces.c (Finternal_merge_in_global_face)
(realize_default_face): Prevent redisplay while the default face
is being realized.  (Bug#71176)

(cherry picked from commit 74b8043e60dde6710d0ba413278c2cb36a84f8f2)

src/xdisp.c
src/xfaces.c

index 7a00b297d61ba777760a4679d4fcfb37710097c9..47675fcc80a3f04cc4d824ea20a8cce6fc57116f 100644 (file)
@@ -13377,8 +13377,10 @@ echo_area_display (bool update_frame_p)
   w = XWINDOW (mini_window);
   f = XFRAME (WINDOW_FRAME (w));
 
-  /* Don't display if frame is invisible or not yet initialized.  */
-  if (!FRAME_REDISPLAY_P (f) || !f->glyphs_initialized_p)
+  /* Don't display if frame is invisible or not yet initialized or
+     if redisplay is inhibited.  */
+  if (!FRAME_REDISPLAY_P (f) || !f->glyphs_initialized_p
+      || !NILP (Vinhibit_redisplay))
     return;
 
 #ifdef HAVE_WINDOW_SYSTEM
index 5192b22ce0af9b377640de6279556cf8eaa2e8d0..258fbc52e64f35b92f23c8648fb0a5fe9e5ca50c 100644 (file)
@@ -4246,6 +4246,12 @@ Default face attributes override any local face attributes.  */)
       /* This can be NULL (e.g., in batch mode).  */
       if (oldface)
        {
+         /* In some cases, realize_face below can call Lisp, which could
+             trigger redisplay.  But we are in the process of realizing
+             the default face, and therefore are not ready to do display.  */
+         specpdl_ref count = SPECPDL_INDEX ();
+         specbind (Qinhibit_redisplay, Qt);
+
          /* Ensure that the face vector is fully specified by merging
             the previously-cached vector.  */
          memcpy (attrs, oldface->lface, sizeof attrs);
@@ -4291,6 +4297,8 @@ Default face attributes override any local face attributes.  */)
                              gvec[LFACE_BACKGROUND_INDEX]);
              Fmodify_frame_parameters (frame, arg);
            }
+
+         unbind_to (count, Qnil);
        }
     }
 
@@ -5959,7 +5967,13 @@ realize_default_face (struct frame *f)
   eassert (lface_fully_specified_p (XVECTOR (lface)->contents));
   check_lface (lface);
   memcpy (attrs, xvector_contents (lface), sizeof attrs);
+  /* In some cases, realize_face below can call Lisp, which could
+     trigger redisplay.  But we are in the process of realizing
+     the default face, and therefore are not ready to do display.  */
+  specpdl_ref count = SPECPDL_INDEX ();
+  specbind (Qinhibit_redisplay, Qt);
   struct face *face = realize_face (c, attrs, DEFAULT_FACE_ID);
+  unbind_to (count, Qnil);
 
 #ifndef HAVE_WINDOW_SYSTEM
   (void) face;