Handle the case when the vertical candidate data source is gone.

This commit is contained in:
Lukhnos D. Liu 2012-03-29 21:04:30 -07:00
parent b0b5dd0233
commit 005437db28
1 changed files with 8 additions and 2 deletions

View File

@ -197,7 +197,13 @@ static const CGFloat kCandidateTextLeftMargin = 8.0;
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
NSString *candidate = [_delegate candidateController:self candidateAtIndex:row];
NSString *candidate = @"";
// rendering can occur when the delegate is already gone or data goes stale; in that case we ignore it
if (row < [_delegate candidateCountForController:self]) {
candidate = [_delegate candidateController:self candidateAtIndex:row];
}
NSAttributedString *attrString = [[[NSAttributedString alloc] initWithString:candidate attributes:[NSDictionary dictionaryWithObjectsAndKeys:_candidateFont, NSFontAttributeName, _candidateTextParagraphStyle, NSParagraphStyleAttributeName, nil]] autorelease];