From 9888043e13759c98f518c0b4bc71a92e2f63a9cb Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Thu, 10 Dec 2009 05:16:30 +0000 Subject: [PATCH] calculate the message attributes when opening the window, to avoid constant checking for nil --- macosx/MessageWindowController.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/macosx/MessageWindowController.m b/macosx/MessageWindowController.m index 2c0480a0f..ea51092f9 100644 --- a/macosx/MessageWindowController.m +++ b/macosx/MessageWindowController.m @@ -110,6 +110,9 @@ clearButtonFrame.origin.x -= clearButtonFrame.size.width - oldClearButtonWidth; [fClearButton setFrame: clearButtonFrame]; + fAttributes = [[[[[fMessageTable tableColumnWithIdentifier: @"Message"] dataCell] attributedStringValue] + attributesAtIndex: 0 effectiveRange: NULL] retain]; + //select proper level in popup button switch ([[NSUserDefaults standardUserDefaults] integerForKey: @"MessageLevel"]) { @@ -250,12 +253,9 @@ #warning don't cut off end - (CGFloat) tableView: (NSTableView *) tableView heightOfRow: (NSInteger) row { - NSTableColumn * column = [tableView tableColumnWithIdentifier: @"Message"]; - - if (!fAttributes) - fAttributes = [[[[column dataCell] attributedStringValue] attributesAtIndex: 0 effectiveRange: NULL] retain]; - NSString * message = [[fDisplayedMessages objectAtIndex: row] objectForKey: @"Message"]; + + NSTableColumn * column = [tableView tableColumnWithIdentifier: @"Message"]; const CGFloat count = floorf([message sizeWithAttributes: fAttributes].width / [column width]); return [tableView rowHeight] * (count + 1.0); }