Skip navigation.
 
mlRe: [NSMatrix putCell:] raising an exception
FROM : Fritz Anderson
DATE : Sat Nov 20 23:07:54 2004

My guess is that NSMatrix (or your subclass of it) caches the pointer 
to the selected cell (there is a _selectedCell member of NSMatrix), and 
does not do a separate retain/release on it. Replacing the only cell in 
the matrix would replace the selected cell (thus releasing it), but 
apparently not update the _selectedCell member, which carries the 
pointer to the stale, released original cell. Later code queries for 
_selectedCell's focus ring type, and NSZombie throws an exception.

The above explanation assumes you aren't releasing the original NSCell 
yourself (you shouldn't), and that NSMatrix is therefore vulnerable.

If your NSMatrix subclass changes the handling of selections or 
membership without referring to the superclass method, you should look 
into that.

If neither of the above is the case, try [pixMatrix selectCellAtRow: -1 
column: 0]; before replacing the cell in the matrix.

   -- F

On 17 Nov 2004, at 5:35 PM, Stephan Burlot wrote:

> // over simplified code
>     theCell = [pixMatrix cellAtRow:row column:column];
>     matrixCell = [[CMCell alloc] init] autorelease];
>     [pixMatrix putCell:matrixCell atRow:row column:column];
>
> with row = 0, column = 0, theCell and matrixCell are not NULL.
>
> I get an exception:
> 2004-11-18 00:06:08.779 ColorMailer[8807] *** *** Selector 
> 'focusRingType' sent to dealloced instance 0x3e37a0 of class CMCell.
>
> in gbd, 0x3e37a0 is theCell.
>
> This happens ONLY if:
> - there is only one cell in the matrix
> - and this is called after a modal window (runModalForWindow) was 
> displayed on screen.
>
> In all other cases, it works.
> It seems like *something* needs to be updated in response to the 
> dismissal of the modal window.
>
> (gdb info below, if needed)
> Any ideas?
>
> Thanks,
> Stephan
>
>
> (gdb) info stack
> #0  0x90aaaba0 in -[_NSZombie methodSignatureForSelector:] ()
> #1  0x909fcea0 in -[NSObject(NSForwardInvocation) forward::] ()
> #2  0x90836810 in _objc_msgForward ()
> #3  0x92e413a8 in -[NSControl focusRingType] ()
> #4  0x92e2e7d0 in -[NSView(NSInternal) _effectiveFocusRingType] ()
> #5  0x92e55734 in -[NSView setKeyboardFocusRingNeedsDisplayInRect:] ()
> #6  0x92f0077c in -[NSMatrix _setNeedsDisplayInRow:column:] ()
> #7  0x92e95b44 in -[NSMatrix updateCell:] ()
> #8  0x92eda008 in -[NSMatrix putCell:atRow:column:] ()
> #9  0x004b35f8 in -[CMController updateCell:withPhoto:] 
> (self=0x54d520, _cmd=0x4b8e98, theCell=0x5e3cf0, photo=0x511e60) at 
> /Users/stephan/develop/cocoa/ColorMailer/sources/CMController.m:660
> #10 0x004b2b40 in -[CMController showCroppingPanel:] (self=0x54d520, 
> _cmd=0x4b8f30, sender=0x54d520) at 
> /Users/stephan/develop/cocoa/ColorMailer/sources/CMController.m:469
> #11 0x004b36dc in -[CMController cropAfterDoubleClick] (self=0x54d520, 
> _cmd=0x4b8e80) at 
> /Users/stephan/develop/cocoa/ColorMailer/sources/CMController.m:677
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list      (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/
> <email_removed>
>
> This email sent to <email_removed>
>

Related mailsAuthorDate
ml[NSMatrix putCell:] raising an exception Stephan Burlot Nov 18, 00:35
mlRe: [NSMatrix putCell:] raising an exception Fritz Anderson Nov 20, 23:07
mlRe: [NSMatrix putCell:] raising an exception Stephan Burlot Nov 22, 13:30