On Aug 10, 2011, at 3:51 AM, Quincey Morris wrote: > It's not entirely clear what it is you're expecting here.
What I'm expecting is that when I close a document, the document, the window controller and the window will disappear. > > AFAICT -- and I have spent some time pondering the documentation and APIs on > this -- there really *isn't* anything that you could call "closing a window" > other than the sequence you describe above. Again AFAICT, window closing and > ordering-out are indistinguishable, for all practical purposes at least. I only noticed the problem from the scripting interface. Let's say I have two documents open: the (pretty standard) scripting interface shows two documents and two windows. If I close the documents, it shows no documents but still two windows -- which I can make reappear by setting their isVisible property. > > The only difference that might happen at close time, which you'd normally > want for a document window, is that the window might get released. (In GC > terms, there might be no strong references and so the NIB objects can get > garbage collected.) That's where things can get a little murky, because there > are sometimes unexpected strong references. > > The most obvious cause of this kind of lingering is the NIB mechanism itself. > Normally, top level objects in a NIB receive an extra retain when loaded > (have an extra strong reference, in the GC case). For windows specifically, > there is a checkbox in IB that says "release when closed". For a document > window, you should check this box so that (presumably) when the window is > closed the extra strong reference is discarded. I have Release when closed checked, but the docs say: "Release when closed, however, is ignored for windows owned by window controllers." Elsewhere it says: "The general behavior is as follows: "• When the last window of a document is closed, the document is also closed. The window, window controller, and document are all released." I'm trying to understand what might stop that from happening. > > If that's not it, then use the debugger's 'info gc-roots' command (having set > a breakpoint somewhere after the window has been closed and the collector has > had time to run, preferably) to find out what's keeping the window alive. Thanks for the suggestion. -- Shane Stanley <[email protected]> 'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/> _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
