Re: NSTableView not retaining its data source. What to do?
Re: NSTableView not retaining its data source. What to do?
- Subject: Re: NSTableView not retaining its data source. What to do?
- From: Kurt Revis <email@hidden>
- Date: Sun, 18 Nov 2001 17:01:26 -0800
I have a NSTableView inside a drawer belonging to a window. The window
is owned by a NSWindowController subclass which serves also as the
NSTableDataSource for the NSTableView and as NSWindow delegate. When
the window controller gets a windowWillClose, it does [self
autorelease] (since the it does not belong to a NSDocument). What
happens then is that if the drawer was open and items were selected in
the NSTableView, the NSTableView will call the window controller (which
is its data source) *after* it's been deallocated.
Is this normal? If it is, is it a bug in NSTableView? Anyway, what can
I do to avoid it? (Is it OK to setDataSource of the NSTableView to nil
when the original data source is deallocated? Is it better to remove
the NSTableView from its superview, and thus hopefully have it
deallocated before its data source is?)
I'm not sure if I consider it a bug or not... what is causing the table
view to talk to its data source? (That is, can you set a breakpoint
somehow, and then look up the call stack to see what's going on?)
Anyway, the easy workaround would be to call [tableView
setDataSource:nil] in the window controller's windowWillClose, before it
autoreleases itself. I can't imagine anything bad would happen because
of this--worst case, your table view might blink briefly just before it
goes offscreen. Removing the table view from its superview would most
likely also work, but I think that's overkill.
--
Kurt Revis
email@hidden