From 7984a11b0310575e0e5bbacac26f9c8f609f8da2 Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Tue, 22 Dec 2015 00:45:09 +0000 Subject: [PATCH] #6039: Fix uninitialized controlView use in InfoTabButtonCell --- macosx/InfoTabButtonCell.m | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/macosx/InfoTabButtonCell.m b/macosx/InfoTabButtonCell.m index 4b9c7cf4d..2b2aa8fa6 100644 --- a/macosx/InfoTabButtonCell.m +++ b/macosx/InfoTabButtonCell.m @@ -28,8 +28,6 @@ - (void) awakeFromNib { - [(NSMatrix *)[self controlView] setToolTip: [self title] forCell: self]; - NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; [nc addObserver: self selector: @selector(updateControlTint:) name: NSControlTintDidChangeNotification object: NSApp]; @@ -38,7 +36,6 @@ //expects the icon to currently be set as the image fIcon = [[self image] retain]; - [self setSelectedTab: fSelected]; } - (void) dealloc @@ -49,10 +46,26 @@ [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 { fSelected = selected; + if ([self controlView] == nil) + return; + NSInteger row, col; [(NSMatrix *)[self controlView] getRow: &row column: &col ofCell: self]; NSRect tabRect = [(NSMatrix *)[self controlView] cellFrameAtRow: row column: col];