#6039: Fix uninitialized controlView use in InfoTabButtonCell

This commit is contained in:
Mike Gelfand 2015-12-22 00:45:09 +00:00
parent 232778b11a
commit 7984a11b03
1 changed files with 16 additions and 3 deletions

View File

@ -28,8 +28,6 @@
- (void) awakeFromNib - (void) awakeFromNib
{ {
[(NSMatrix *)[self controlView] setToolTip: [self title] forCell: self];
NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
[nc addObserver: self selector: @selector(updateControlTint:) [nc addObserver: self selector: @selector(updateControlTint:)
name: NSControlTintDidChangeNotification object: NSApp]; name: NSControlTintDidChangeNotification object: NSApp];
@ -38,7 +36,6 @@
//expects the icon to currently be set as the image //expects the icon to currently be set as the image
fIcon = [[self image] retain]; fIcon = [[self image] retain];
[self setSelectedTab: fSelected];
} }
- (void) dealloc - (void) dealloc
@ -49,10 +46,26 @@
[super dealloc]; [super dealloc];
} }
- (void) setControlView: (NSView *) controlView
{
const BOOL hadControlView = [self controlView] != nil;
[super setControlView: controlView];
if (!hadControlView)
{
[(NSMatrix *)[self controlView] setToolTip: [self title] forCell: self];
[self setSelectedTab: fSelected];
}
}
- (void) setSelectedTab: (BOOL) selected - (void) setSelectedTab: (BOOL) selected
{ {
fSelected = selected; fSelected = selected;
if ([self controlView] == nil)
return;
NSInteger row, col; NSInteger row, col;
[(NSMatrix *)[self controlView] getRow: &row column: &col ofCell: self]; [(NSMatrix *)[self controlView] getRow: &row column: &col ofCell: self];
NSRect tabRect = [(NSMatrix *)[self controlView] cellFrameAtRow: row column: col]; NSRect tabRect = [(NSMatrix *)[self controlView] cellFrameAtRow: row column: col];