Index: /trunk/source/cocoa-ide/cocoa-editor.lisp
===================================================================
--- /trunk/source/cocoa-ide/cocoa-editor.lisp	(revision 12785)
+++ /trunk/source/cocoa-ide/cocoa-editor.lisp	(revision 12786)
@@ -2049,19 +2049,4 @@
     (when (and pane (not (%null-ptr-p pane)))
       (report-condition-in-hemlock-frame condition (#/window pane)))))
-                       
-(objc:defmethod (#/close :void) ((self hemlock-frame))
-  (let* ((content-view (#/contentView self))
-         (subviews (#/subviews content-view)))
-    (do* ((i (1- (#/count subviews)) (1- i)))
-         ((< i 0))
-      (#/removeFromSuperviewWithoutNeedingDisplay (#/objectAtIndex: subviews i))))
-  (let* ((buf (hemlock-frame-echo-area-buffer self))
-         (echo-doc (if buf (hi::buffer-document buf))))
-    (when echo-doc
-      (setf (hemlock-frame-echo-area-buffer self) nil)
-      (#/close echo-doc)))
-  (release-canonical-nsobject self)
-  (#/setFrameAutosaveName: self #@"")
-  (call-next-method))
 
 (defun window-menubar-height ()
@@ -2396,4 +2381,18 @@
             (ns:ns-rect-y r) (ns:ns-rect-y default-frame)))
     r))
+
+(objc:defmethod (#/windowWillClose: :void) ((wc hemlock-editor-window-controller)
+                                            notification)
+  (declare (ignore notification))
+  ;; The echo area "document" should probably be a slot in the document
+  ;; object, and released when the document object is.
+  (let* ((w (#/window wc))
+         (buf (hemlock-frame-echo-area-buffer w))
+         (echo-doc (if buf (hi::buffer-document buf))))
+    (when echo-doc
+      (setf (hemlock-frame-echo-area-buffer w) nil)
+      (#/close echo-doc))
+    (#/setFrameAutosaveName: w #@"")
+    (#/autorelease w)))
 
 (defmethod hemlock-view ((self hemlock-editor-window-controller))
