changeset 38434:86a4e78aeae0

(clear_face_cache): Clear fonts on a display basis. Clear faces afterwards. (clear_font_table): Take a x_display_info parameter. Don't free fonts being the default font of any frame on the given display.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 16 Jul 2001 12:21:02 +0000
parents 02ea605273b3
children a9102b5472f0
files src/xfaces.c
diffstat 1 files changed, 32 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfaces.c	Mon Jul 16 11:54:17 2001 +0000
+++ b/src/xfaces.c	Mon Jul 16 12:21:02 2001 +0000
@@ -597,7 +597,7 @@
 			       int (*cmpfn) P_ ((const void *, const void *))));
 static GC x_create_gc P_ ((struct frame *, unsigned long, XGCValues *));
 static void x_free_gc P_ ((struct frame *, GC));
-static void clear_font_table P_ ((struct frame *));
+static void clear_font_table P_ ((struct x_display_info *));
 
 #ifdef WINDOWSNT
 extern Lisp_Object w32_list_fonts P_ ((struct frame *, Lisp_Object, int, int));
@@ -979,6 +979,14 @@
   if (clear_fonts_p
       || ++clear_font_table_count == CLEAR_FONT_TABLE_COUNT)
     {
+      struct x_display_info *dpyinfo;
+      
+      /* Fonts are common for frames on one display, i.e. on
+	 one X screen.  */
+      for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
+	if (dpyinfo->n_fonts > CLEAR_FONT_TABLE_NFONTS)
+	  clear_font_table (dpyinfo);
+      
       /* From time to time see if we can unload some fonts.  This also
 	 frees all realized faces on all frames.  Fonts needed by
 	 faces will be loaded again when faces are realized again.  */
@@ -986,13 +994,10 @@
 
       FOR_EACH_FRAME (tail, frame)
 	{
-	  f = XFRAME (frame);
+	  struct frame *f = XFRAME (frame);
 	  if (FRAME_WINDOW_P (f)
 	      && FRAME_X_DISPLAY_INFO (f)->n_fonts > CLEAR_FONT_TABLE_NFONTS)
-	    {
-	      free_all_realized_faces (frame);
-	      clear_font_table (f);
-	    }
+	    free_all_realized_faces (frame);
 	}
     }
   else
@@ -1034,21 +1039,32 @@
    from time to time.  */
 
 static void
-clear_font_table (f)
-     struct frame *f;
-{
-  struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+clear_font_table (dpyinfo)
+     struct x_display_info *dpyinfo;
+{
   int i;
 
-  xassert (FRAME_WINDOW_P (f));
-
-  /* Free those fonts that are not used by the frame F as the default.  */
+  /* Free those fonts that are not used by frames on DPYINFO.  */
   for (i = 0; i < dpyinfo->n_fonts; ++i)
     {
       struct font_info *font_info = dpyinfo->font_table + i;
-
-      if (!font_info->name
-	  || font_info->font == FRAME_FONT (f))
+      Lisp_Object tail, frame;
+
+      /* Check if slot is already free.  */
+      if (font_info->name == NULL)
+	continue;
+
+      /* Don't free a default font of some frame on this display.  */
+      FOR_EACH_FRAME (tail, frame)
+	{
+	  struct frame *f = XFRAME (frame);
+	  if (FRAME_WINDOW_P (f)
+	      && FRAME_X_DISPLAY_INFO (f) == dpyinfo
+	      && font_info->font == FRAME_FONT (f))
+	    break;
+	}
+
+      if (!NILP (tail))
 	continue;
 
       /* Free names.  */