diff src/buffer.c @ 44:8d2a9b52c682 r19-15prefinal

Import from CVS: tag r19-15prefinal
author cvs
date Mon, 13 Aug 2007 08:55:10 +0200
parents 7e54bd776075
children 56c54cf7c5b6
line wrap: on
line diff
--- a/src/buffer.c	Mon Aug 13 08:54:52 2007 +0200
+++ b/src/buffer.c	Mon Aug 13 08:55:10 2007 +0200
@@ -1210,7 +1210,7 @@
 */
        (bufname))
 {
-  /* This function can GC */
+  /* This function can call lisp */
   Lisp_Object buf;
   REGISTER struct buffer *b;
   struct gcpro gcpro1, gcpro2;
@@ -1378,7 +1378,26 @@
 	&& BUF_SAVE_MODIFF (b) < b->auto_save_modified)
       {
 	if (!NILP (Vdelete_auto_save_files))
-	  internal_delete_file (b->auto_save_file_name);
+	  {
+	    /* deleting the auto save file might kill b! */
+	    /* #### dmoore - fix this crap, we do this same gcpro and
+	       buffer liveness check multiple times.  Let's get a
+	       macro or something for it. */
+	    GCPRO1 (buf);
+	    internal_delete_file (b->auto_save_file_name);
+	    UNGCPRO;
+	    b = XBUFFER (buf);
+	    
+	    if (!BUFFER_LIVE_P (b))
+	      return Qnil;
+
+	    if (b == current_buffer)
+	      {
+		Fset_buffer (Fother_buffer (buf, Qnil, Qnil));
+		if (b == current_buffer)
+		  return Qnil;
+	      }
+	  }
       }
 
     uninit_buffer_markers (b);