diff src/alloc.c @ 161:28f395d8dc7a r20-3b7

Import from CVS: tag r20-3b7
author cvs
date Mon, 13 Aug 2007 09:42:26 +0200
parents 7d55a9ba150c
children 0132846995bd
line wrap: on
line diff
--- a/src/alloc.c	Mon Aug 13 09:41:47 2007 +0200
+++ b/src/alloc.c	Mon Aug 13 09:42:26 2007 +0200
@@ -3956,12 +3956,12 @@
   char stack_top_variable;
   extern char *stack_bottom;
   int i;
-  struct frame *f = selected_frame ();
   int speccount = specpdl_depth ();
   Lisp_Object pre_gc_cursor = Qnil;
+  Lisp_Object changed_frames = Qnil;
   struct gcpro gcpro1;
 
-  int cursor_changed = 0;
+  int cursor_changed_selected_frame = 0;
 
   if (gc_in_progress != 0)
     return;
@@ -3972,7 +3972,7 @@
   if (preparing_for_armageddon)
     return;
 
-  GCPRO1 (pre_gc_cursor);
+  GCPRO1 (changed_frames);
 
   /* Very important to prevent GC during any of the following
      stuff that might run Lisp code; otherwise, we'll likely
@@ -3987,36 +3987,55 @@
   /* Now show the GC cursor/message. */
   if (!noninteractive)
     {
-      if (FRAME_WIN_P (f))
+      /* No need to gcpro this; gc won't catch us now. */
+      Lisp_Object frmcons, devcons, concons;
+      Lisp_Object selframe = make_frame (selected_frame ());
+
+      FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
 	{
-	  Lisp_Object frame = make_frame (f);
-	  Lisp_Object cursor = glyph_image_instance (Vgc_pointer_glyph,
-						     FRAME_SELECTED_WINDOW (f),
-						     ERROR_ME_NOT, 1);
-	  pre_gc_cursor = f->pointer;
-	  if (POINTER_IMAGE_INSTANCEP (cursor)
-	      /* don't change if we don't know how to change back. */
-	      && POINTER_IMAGE_INSTANCEP (pre_gc_cursor))
+	  struct frame *f = XFRAME (XCAR (frmcons));
+	  int cursor_changed;
+
+	  if (FRAME_WIN_P (f))
 	    {
-	      cursor_changed = 1;
-	      Fset_frame_pointer (frame, cursor);
+	      Lisp_Object frame = XCAR (frmcons);
+	      Lisp_Object cursor =
+		glyph_image_instance (Vgc_pointer_glyph,
+				      FRAME_SELECTED_WINDOW (f),
+				      ERROR_ME_NOT, 1);
+	      pre_gc_cursor = f->pointer;
+	      if (POINTER_IMAGE_INSTANCEP (cursor)
+		  /* don't change if we don't know how to change back. */
+		  && POINTER_IMAGE_INSTANCEP (pre_gc_cursor))
+		{
+		  Fset_frame_pointer (frame, cursor);
+		  /* Add the frame to the list. */
+		  changed_frames = Fcons (pre_gc_cursor, changed_frames);
+		  changed_frames = Fcons (XCAR (frmcons), changed_frames);
+		  if (EQ (XCAR (frmcons), selframe))
+		    cursor_changed_selected_frame = 1;
+		}
 	    }
 	}
-
-      /* Don't print messages to the stream device. */
-      if (!cursor_changed && !FRAME_STREAM_P (f))
-	{
-	  char *msg = (STRINGP (Vgc_message)
-		       ? GETTEXT ((char *) XSTRING_DATA (Vgc_message))
-		       : 0);
-	  Lisp_Object args[2], whole_msg;
-	  args[0] = build_string (msg ? msg :
-				  GETTEXT ((CONST char *) gc_default_message));
-	  args[1] = build_string ("...");
-	  whole_msg = Fconcat (2, args);
-	  echo_area_message (f, (Bufbyte *) 0, whole_msg, 0, -1,
-			     Qgarbage_collecting);
-	}
+      /* Now handle the plain old message. */
+      {
+	struct frame *f = XFRAME (selframe);
+	/* Don't print messages to the stream device. */
+	if (!cursor_changed_selected_frame && !FRAME_STREAM_P (f))
+	  {
+	    char *msg = (STRINGP (Vgc_message)
+			 ? GETTEXT ((char *) XSTRING_DATA (Vgc_message))
+			 : 0);
+	    Lisp_Object args[2], whole_msg;
+	    args[0] =
+	      build_string (msg ? msg :
+			    GETTEXT ((CONST char *) gc_default_message));
+	    args[1] = build_string ("...");
+	    whole_msg = Fconcat (2, args);
+	    echo_area_message (f, (Bufbyte *) 0, whole_msg, 0, -1,
+			       Qgarbage_collecting);
+	  }
+      }
     }
 
   /***** Now we actually start the garbage collection. */
@@ -4152,9 +4171,13 @@
   /* Now remove the GC cursor/message */
   if (!noninteractive)
     {
-      if (cursor_changed)
-	Fset_frame_pointer (make_frame (f), pre_gc_cursor);
-      else if (!FRAME_STREAM_P (f))
+      Lisp_Object tail = changed_frames;
+      while (CONSP (tail) && CONSP (XCDR (tail)))
+	{
+	  Fset_frame_pointer (XCAR (tail), XCAR (XCDR (tail)));
+	  tail = XCDR (XCDR (tail));
+	}
+      if (!cursor_changed_selected_frame && !FRAME_STREAM_P (selected_frame ()))
 	{
 	  char *msg = (STRINGP (Vgc_message)
 		       ? GETTEXT ((char *) XSTRING_DATA (Vgc_message))