changeset 1207:02cf044d5fce

[xemacs-hg @ 2003-01-14 16:54:02 by michaels] 2003-01-11 Mike Sperber <mike@xemacs.org> * window.c (Fdelete_window): Make sure that f->last_nonminibuf_window is set to a live window once we're done. (contains_window): Abstract this code out of Fdelete_window. 2003-01-10 Mike Sperber <mike@xemacs.org> * window.c (Fdelete_other_windows): Prevent crash for combination windows.
author michaels
date Tue, 14 Jan 2003 16:54:03 +0000
parents d213714eb925
children b724c5a1f7ea
files src/ChangeLog src/window.c
diffstat 2 files changed, 51 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Mon Jan 13 22:52:31 2003 +0000
+++ b/src/ChangeLog	Tue Jan 14 16:54:03 2003 +0000
@@ -1,3 +1,14 @@
+2003-01-11  Mike Sperber  <mike@xemacs.org>
+
+	* window.c (Fdelete_window): Make sure that
+	f->last_nonminibuf_window is set to a live window once we're done.
+	(contains_window): Abstract this code out of Fdelete_window.
+
+2003-01-10  Mike Sperber  <mike@xemacs.org>
+
+	* window.c (Fdelete_other_windows): Prevent crash for combination
+	windows.
+
 2003-01-08  Mike Sperber <mike@xemacs.org>
 
 	* console.h (CDFW_CONSOLE): Don't lead to a crash if we're dealing
--- a/src/window.c	Mon Jan 13 22:52:31 2003 +0000
+++ b/src/window.c	Tue Jan 14 16:54:03 2003 +0000
@@ -2150,6 +2150,20 @@
   note_object_deleted (wrap_window (w));
 }
 
+/* Check if window contains pwindow. */
+
+static int
+contains_window (Lisp_Object window, Lisp_Object pwindow)
+{
+    while (!NILP (pwindow))
+      {
+	if (EQ (window, pwindow))
+	  return 1;
+	pwindow = XWINDOW (pwindow)->parent;
+      }
+    return 0;
+}
+
 DEFUN ("delete-window", Fdelete_window, 0, 2, "", /*
 Remove WINDOW from the display.  Default is selected window.
 If window is the only one on its frame, the frame is deleted as well.
@@ -2226,35 +2240,27 @@
      So, we check by scanning all the ancestors of the
      frame's selected window and comparing each one with
      WINDOW.  */
-  {
-    Lisp_Object pwindow;
-
-    pwindow = FRAME_SELECTED_WINDOW (f);
-
-    while (!NILP (pwindow))
-      {
-	if (EQ (window, pwindow))
-	  break;
-	pwindow = XWINDOW (pwindow)->parent;
-      }
-
-    if (EQ (window, pwindow))
-      {
-	/* OK, we found it. */
-	Lisp_Object alternative;
-	alternative = Fnext_window (window, Qlambda, Qnil, Qnil);
-
-	/* If we're about to delete the selected window on the
-	   selected frame, then we should use Fselect_window to select
-	   the new window.  On the other hand, if we're about to
-	   delete the selected window on any other frame, we shouldn't do
-	   anything but set the frame's selected_window slot.  */
-	if (EQ (frame, Fselected_frame (Qnil)))
-	  Fselect_window (alternative, Qnil);
-	else
-	  set_frame_selected_window (f, alternative);
-      }
-  }
+  if (contains_window (window, FRAME_SELECTED_WINDOW (f)))
+    {
+      Lisp_Object alternative;
+      alternative = Fnext_window (window, Qlambda, Qnil, Qnil);
+      
+      /* #### */
+      /* If we're about to delete the selected window on the
+	 selected frame, then we should use Fselect_window to select
+	 the new window.  On the other hand, if we're about to
+	 delete the selected window on any other frame, we shouldn't do
+	 anything but set the frame's selected_window slot.  */
+      if (EQ (frame, Fselected_frame (Qnil)))
+	Fselect_window (alternative, Qnil);
+      else
+	set_frame_selected_window (f, alternative);
+    }
+
+  /* Some display parameters (gutter display specifically) depend on
+     FRAME_LAST_NONMINIBUF (f) to be set to a live window.  Ensure that. */
+  if (contains_window (window, FRAME_LAST_NONMINIBUF_WINDOW (f)))
+    f->last_nonminibuf_window = Fnext_window (window, Qlambda, Qnil, Qnil);
 
   /* w->buffer is nil in a non-leaf window; in this case,
      get rid of the markers we maintain that point into that buffer. */
@@ -3194,11 +3200,15 @@
        (window))
 {
   struct window *w = decode_window (window);
-  struct buffer *b = XBUFFER (w->buffer);
+  struct buffer *b;
   Charbpos start_pos;
   int old_top = WINDOW_TOP (w);
 
+  if (NILP (WINDOW_BUFFER (w)))
+    invalid_operation ("Can't delete other windows of combination", window);
+
   window = wrap_window (w);
+  b = XBUFFER (WINDOW_BUFFER (w));
 
   if (MINI_WINDOW_P (w) && old_top > 0)
     invalid_operation ("Can't expand minibuffer to full frame", Qunbound);