Don't delete a window if it's already deleted.
authorChris Hanson <org/chris-hanson/cph>
Mon, 30 Oct 2000 19:18:54 +0000 (19:18 +0000)
committerChris Hanson <org/chris-hanson/cph>
Mon, 30 Oct 2000 19:18:54 +0000 (19:18 +0000)
v7/src/edwin/comwin.scm

index 04d7c9019b6564ed9767f2fab06bd5782e7f579c..297505dcb73c76714bcaf94160d9da7859f9b926 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: comwin.scm,v 1.145 2000/10/26 22:12:47 cph Exp $
+;;; $Id: comwin.scm,v 1.146 2000/10/30 19:18:54 cph Exp $
 ;;;
 ;;; Copyright (c) 1985, 1989-1999 Massachusetts Institute of Technology
 ;;;
 
 (define (window-delete! leaf #!optional merge-into)
   (check-leaf-window leaf 'WINDOW-DELETE!)
-  (let ((screen (window-screen leaf)))
-    (without-interrupts
-     (lambda ()
-       (let ((superior (window-superior leaf))
-            (next (window-next leaf))
-            (previous (window-previous leaf))
-            (x-size (window-x-size leaf))
-            (y-size (window-y-size leaf)))
-        (if (not (combination? superior))
-            (editor-error "Window has no neighbors; can't delete"))
-        (let ((adjust-size!
-               (lambda (window)
-                 (if (current-window? leaf)
-                     (select-window
-                      (let loop ((window window))
-                        (if (combination? window)
-                            (loop (combination-child window))
-                            window))))
-                 (unlink-leaf! leaf)
-                 (if (combination-vertical? superior)
-                     (=> window :set-y-size!
-                         (+ (window-y-size window) y-size))
-                     (=> window :set-x-size!
-                         (+ (window-x-size window) x-size))))))
-          (let ((do-next
-                 (lambda ()
-                   (adjust-size! next)
-                   (let ((inferior (window-inferior superior next)))
+  (if (window-live? leaf)
+      (let ((screen (window-screen leaf)))
+       (without-interrupts
+        (lambda ()
+          (let ((superior (window-superior leaf))
+                (next (window-next leaf))
+                (previous (window-previous leaf))
+                (x-size (window-x-size leaf))
+                (y-size (window-y-size leaf)))
+            (if (not (combination? superior))
+                (editor-error "Window has no neighbors; can't delete"))
+            (let ((adjust-size!
+                   (lambda (window)
+                     (if (current-window? leaf)
+                         (select-window
+                          (let loop ((window window))
+                            (if (combination? window)
+                                (loop (combination-child window))
+                                window))))
+                     (unlink-leaf! leaf)
                      (if (combination-vertical? superior)
-                         (set-inferior-y-start!
-                          inferior
-                          (- (inferior-y-start inferior) y-size))
-                         (set-inferior-x-start!
-                          inferior
-                          (- (inferior-x-start inferior) x-size))))))
-                (do-previous
-                 (lambda ()
-                   (adjust-size! previous))))
-            (cond ((and (not (default-object? merge-into))
-                        merge-into
-                        (or (eq? merge-into next) (eq? merge-into previous)))
-                   (if (eq? merge-into next)
-                       (do-next)
-                       (do-previous)))
-                  (next (do-next))
-                  (previous (do-previous))
-                  (else (error "Combination with single child:" superior)))))
-        (maybe-delete-combination! superior))))
-    (maybe-deselect-buffer-layout screen)))
+                         (=> window :set-y-size!
+                             (+ (window-y-size window) y-size))
+                         (=> window :set-x-size!
+                             (+ (window-x-size window) x-size))))))
+              (let ((do-next
+                     (lambda ()
+                       (adjust-size! next)
+                       (let ((inferior (window-inferior superior next)))
+                         (if (combination-vertical? superior)
+                             (set-inferior-y-start!
+                              inferior
+                              (- (inferior-y-start inferior) y-size))
+                             (set-inferior-x-start!
+                              inferior
+                              (- (inferior-x-start inferior) x-size))))))
+                    (do-previous
+                     (lambda ()
+                       (adjust-size! previous))))
+                (cond ((and (not (default-object? merge-into))
+                            merge-into
+                            (or (eq? merge-into next)
+                                (eq? merge-into previous)))
+                       (if (eq? merge-into next)
+                           (do-next)
+                           (do-previous)))
+                      (next (do-next))
+                      (previous (do-previous))
+                      (else
+                       (error "Combination with single child:" superior)))))
+            (maybe-delete-combination! superior))))
+       (maybe-deselect-buffer-layout screen))))
 \f
 (define (unlink-leaf! leaf)
   (let ((combination (window-superior leaf))