Skip navigation.
 
mlRe: NSTreeController woes... NSZombie at doc closed
FROM : Ken Victor
DATE : Mon Jun 12 20:48:43 2006

At 8:25 AM -0700 6/12/06, Andrew Farmer wrote:
>On 11 Jun 06, at 19:20, Ken Victor wrote:

>>one of the windows of my core data document app contains an
>>NSOutlineView bound with a NSTreeController. the basics work fine.
>>however, if i expand a row and then close the document, i get the
>>following stack trace:
>>
>>#0    0x929ffbf8 in -[_NSZombie methodSignatureForSelector:]

><...>

>>
>>and the following on the console log:
>>
>>2006-06-11 18:50:03.677 Accounts[12130] *** Selector 'leafKeyPath'
>>sent to dealloced instance 0x1301670 of class NSTreeController.
>>Break at '-[_NSZombie methodSignatureForSelector:]' to debug.
>>2006-06-11 18:50:04.809 Accounts[12130] *** -[NSAutoreleasePool
>>dealloc]: Exception ignored while releasing an object in an
>>autorelease pool: *** Selector 'leafKeyPath' sent to dealloced
>>instance 0x1301670 of class NSTreeController.
>>Break at '-[_NSZombie methodSignatureForSelector:]' to debug.
>>
>>note that everything close fine if i don't expand any rows while
>>this window is open.

>
>You're probably doing something wrong with memory management
>somewhere in your code; the NSTreeController is getting released too
>early.
>

>>also, by adding the following line of code to my
>>NSWindowController's subclass dealloc method, the problems also go
>>away...

>
>Mind showing us your dealloc method? It's possible that you're doing
>things in the wrong order.



below is the dealloc method of my subclassed NSWindowController and
the dealloc of its superclass and its superclass dealloc -- all the
way up to the first subclass of NSWindowController.

- (void) dealloc {

   if ([self comboBoxNotificationsInstalled]) {
       [[NSNotificationCenter defaultCenter] removeObserver:
self name: newAccountTypeNotification object: nil];
       [[NSNotificationCenter defaultCenter] removeObserver:
self name: deletedAccountTypeNotification object: nil];
       [[NSNotificationCenter defaultCenter] removeObserver:
self name: changedAccountTypeNotification object: nil];
       }

   // uncommenting the below causes the problem to manifest
==========================
//        [[(KVWindow*)[self window] arrayController]
setManagedObjectContext: nil];

   [super dealloc];
   }


- (void) dealloc {

   [self setDeferredObjectsToSelect: nil];

   [[NSNotificationCenter defaultCenter] removeObserver: self
name: [[[self class] entityClass]
entityDescription]->createdEntityNotificationName object: nil];
   [[NSNotificationCenter defaultCenter] removeObserver: self
name: [[[self class] entityClass]
entityDescription]->changedEntityNotificationName object: nil];
   [self setNewEntityWindowController: nil];

   [self setComboBoxNotificationsInstalled: nil];
   [self setPopupNotificationsInstalled: nil];

   [super dealloc];
   }


- (void) dealloc {

   [[NSNotificationCenter defaultCenter] removeObserver: self];

   if (NSTableView* table = [[[self window] contentView]
viewWithTag: 5491])
       [table removeObserver: self forKeyPath: @"sortDescriptors"];

   [self setFilterArray: nil];
   [self setHiddenColumns: nil];
   [self setAllColumns: nil];
   [self setShowColumnsWindowController: nil];
   [self setEditTBI: nil];
   [self setDeleteTBI: nil];
   [[self searchTBI] setView: nil];
   [self setSearchTBI: nil];
   [self setTableFont: nil];
   [self setTableColor: nil];

   [super dealloc];
   }


- (void) dealloc {
   [self setWindowTemplateName: nil];
   [super dealloc];    // super is NSWindowController
   }

Related mailsAuthorDate
mlNSTreeController woes... NSZombie at doc closed Ken Victor Jun 12, 04:20
mlRe: NSTreeController woes... NSZombie at doc closed Andrew Farmer Jun 12, 17:25
mlRe: NSTreeController woes... NSZombie at doc closed Ken Victor Jun 12, 20:48
mlRe: NSTreeController woes... NSZombie at doc closed Ken Victor Jun 13, 00:25
ml[solved] Re: NSTreeController woes... NSZombie at doc closed Ken Victor Jun 13, 01:25