]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid crashes due to clearing of a frame's face cache
authorEli Zaretskii <eliz@gnu.org>
Wed, 15 Sep 2021 13:14:30 +0000 (16:14 +0300)
committerEli Zaretskii <eliz@gnu.org>
Wed, 15 Sep 2021 13:14:30 +0000 (16:14 +0300)
* src/xfaces.c (clear_face_cache): Don't clear fonts and faces of
a frame that is being redisplayed, just because it's time for some
routine maintenance.  (Bug#50571)
* src/xdisp.c (redisplay_internal):
* src/frame.h (struct frame) <inhibit_clear_image_cache>: Update
commentary of using this struct member.

src/frame.h
src/xdisp.c
src/xfaces.c

index a8ad011889d30f1f43d91ddfd1d0c7e51b8349e3..3dd76805dd26fb694f14ce676f4aad0c699c291f 100644 (file)
@@ -449,8 +449,8 @@ struct frame
   /* Non-zero if this frame's faces need to be recomputed.  */
   bool_bf face_change : 1;
 
-  /* Non-zero if this frame's image cache cannot be freed because the
-     frame is in the process of being redisplayed.  */
+  /* Non-zero if this frame's image cache and face cache cannot be
+     freed because the frame is in the process of being redisplayed.  */
   bool_bf inhibit_clear_image_cache : 1;
 
   /* True when new_width or new_height were set by change_frame_size,
index d30a68570f06c0b437d62277eb0715875e6e8cd0..2e72f6b59158580d893fdd53ee82a54d90f62505 100644 (file)
@@ -16061,12 +16061,13 @@ redisplay_internal (void)
              if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f))
                {
 
-                 /* Don't allow freeing images for this frame as long
-                    as the frame's update wasn't completed.  This
-                    prevents crashes when some Lisp that runs from
-                    the various hooks or font-lock decides to clear
-                    the frame's image cache, when the images in that
-                    cache are referenced by the desired matrix.  */
+                 /* Don't allow freeing images and faces for this
+                    frame as long as the frame's update wasn't
+                    completed.  This prevents crashes when some Lisp
+                    that runs from the various hooks or font-lock
+                    decides to clear the frame's image cache and face
+                    cache, when the images and faces in those caches
+                    are referenced by the desired matrix.  */
                  f->inhibit_clear_image_cache = true;
                  redisplay_windows (FRAME_ROOT_WINDOW (f));
                }
index 2273fb4fe4dc446792d84c5fc4cff58e895b8402..aefed54ebcb6edaae0811d7271bcc1ef6698762b 100644 (file)
@@ -674,7 +674,8 @@ clear_face_cache (bool clear_fonts_p)
        {
          struct frame *f = XFRAME (frame);
          if (FRAME_WINDOW_P (f)
-             && FRAME_DISPLAY_INFO (f)->n_fonts > CLEAR_FONT_TABLE_NFONTS)
+             && FRAME_DISPLAY_INFO (f)->n_fonts > CLEAR_FONT_TABLE_NFONTS
+             && !f->inhibit_clear_image_cache)
            {
              clear_font_cache (f);
              free_all_realized_faces (frame);