Re: multiple window per document problems
Re: multiple window per document problems
- Subject: Re: multiple window per document problems
- From: m <email@hidden>
- Date: Sun, 6 Jun 2004 13:34:57 -0700
Ok, I figured it out I think (taking a caffeine break now and then is a
good thing!).
I wasn't autoreleasing the window controllers. Since I was
concentrating on understanding the doc/window controller thing I was
ignoring possible leaks. I assumed that NSDocument explicitly closed
the windows controlled by its window controllers when closing. It looks
like it does not and instead relies on the right thing happening when
it releases its window controllers.
I am still a bit uneasy about this as it seems wiser to do the explicit
thing and not rely on the implicit thing. What I'm looking for now is
confirmation that my theory is in fact correct.
_murat
On Jun 6, 2004, at 12:35 PM, m wrote:
On Jun 6, 2004, at 4:18 AM, mmalcolm crawford wrote:
On Jun 6, 2004, at 4:04 AM, m wrote:
I have a "main" window for my document and several secondary
windows. The main window is created and managed as usual (it comes
from the documents nib file). The secondary windows are handled in a
method of my NSDocument subclass like this:
"NSDocument subclasses must also create their window controllers.
They can do this indirectly or directly. If a document has only one
nib file (with one window in it), the subclass can override
windowNibName to return the name of the window nib file; as a
consequence, a default NSWindowController instance is created for the
document, with the document as the nib files owner. If a document
has multiple windows, or if an instance of a custom
NSWindowController subclass is to be used, the NSDocument subclass
must override makeWindowControllers to create these objects."
First try managing all the window controllers through
'makeWindowControllers'.
Yeah, same result: the doc still stays open when all windows are
closed. Explicitly setting setShouldCloseDocument to YES closes the
document when the window is closed, but the other windows do not close
with the document.
Here's my makeWindowControllers code. I also tried calling [super
makeWindowControllers] to make the "main" controller.
- (void)makeWindowControllers
{
NSWindowController* aWindowController;
aWindowController = [[NSWindowController
alloc]initWithWindowNibName:[self windowNibName] owner:self];
[self addWindowController:aWindowController];
[aWindowController setShouldCloseDocument:YES];
aWindowController = [[NSWindowController
alloc]initWithWindowNibName:@"Subwindow" owner:self];
[self addWindowController:aWindowController];
[aWindowController setShouldCloseDocument:NO];
aWindowController = [[NSWindowController
alloc]initWithWindowNibName:@"Subwindow" owner:self];
[self addWindowController:aWindowController];
[aWindowController setShouldCloseDocument:NO];
}
Am I right in thinking this should all "just work"?
_murat
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.