From: Adam M. <ama...@us...> - 2005-07-22 23:10:17
|
Update of /cvsroot/bibdesk/bibdesk_vendorsrc/ScotlandSoftware/ImagePopUpButton In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10235 Modified Files: RYZImagePopUpButtonCell.m Log Message: Fix crasher that occurs when calling [super dealloc], which tries to set the alternate image to nil. Since we're setting our button cell's image to nil at the same time, we need to be sure that we don't have a garbage pointer to the button cell. Index: RYZImagePopUpButtonCell.m =================================================================== RCS file: /cvsroot/bibdesk/bibdesk_vendorsrc/ScotlandSoftware/ImagePopUpButton/RYZImagePopUpButtonCell.m,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** RYZImagePopUpButtonCell.m 22 Jul 2005 02:05:57 -0000 1.20 --- RYZImagePopUpButtonCell.m 22 Jul 2005 23:10:08 -0000 1.21 *************** *** 1,4 **** --- 1,8 ---- #import "RYZImagePopUpButtonCell.h" + @interface RYZImagePopUpButtonCell (Private) + - (void)setButtonCell:(NSButtonCell *)buttonCell; + @end + @implementation RYZImagePopUpButtonCell *************** *** 18,25 **** { if (self = [super initTextCell:@"" pullsDown:NO]) { ! RYZ_buttonCell = [[NSButtonCell alloc] initTextCell: @""]; ! [RYZ_buttonCell setBordered: NO]; ! [RYZ_buttonCell setHighlightsBy: NSContentsCellMask]; ! [RYZ_buttonCell setImagePosition: NSImageLeft]; RYZ_iconSize = NSMakeSize(32.0, 32.0); --- 22,31 ---- { if (self = [super initTextCell:@"" pullsDown:NO]) { ! NSButtonCell *buttonCell = [[NSButtonCell alloc] initTextCell: @""]; ! [buttonCell setBordered: NO]; ! [buttonCell setHighlightsBy: NSContentsCellMask]; ! [buttonCell setImagePosition: NSImageLeft]; ! [self setButtonCell:buttonCell]; ! [buttonCell release]; RYZ_iconSize = NSMakeSize(32.0, 32.0); *************** *** 39,43 **** { if (self = [super initWithCoder:coder]) { ! RYZ_buttonCell = [[coder decodeObjectForKey:@"buttonCell"] retain]; RYZ_iconSize = NSMakeSize([coder decodeFloatForKey:@"iconSizeWidth"], [coder decodeFloatForKey:@"iconSizeHeight"]); --- 45,49 ---- { if (self = [super initWithCoder:coder]) { ! [self setButtonCell:[coder decodeObjectForKey:@"buttonCell"]]; RYZ_iconSize = NSMakeSize([coder decodeFloatForKey:@"iconSizeWidth"], [coder decodeFloatForKey:@"iconSizeHeight"]); *************** *** 78,82 **** - (void)dealloc { ! [RYZ_buttonCell release]; [RYZ_iconImage release]; [RYZ_arrowImage release]; --- 84,88 ---- - (void)dealloc { ! [self setButtonCell:nil]; // release the ivar and set to nil, or [super dealloc] causes a crash [RYZ_iconImage release]; [RYZ_arrowImage release]; *************** *** 494,495 **** --- 500,513 ---- @end + + @implementation RYZImagePopUpButtonCell (Private) + + - (void)setButtonCell:(NSButtonCell *)buttonCell; + { + if(RYZ_buttonCell != buttonCell){ + [RYZ_buttonCell release]; + RYZ_buttonCell = [buttonCell retain]; + } + } + + @end |