From 23b652d2bc84bc14fa700ca2c979f8113df18448 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Thu, 10 Dec 2009 05:25:12 +0000 Subject: [PATCH] fix a bug with the new message index code --- macosx/MessageWindowController.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/macosx/MessageWindowController.m b/macosx/MessageWindowController.m index ea51092f9..eef7de6cf 100644 --- a/macosx/MessageWindowController.m +++ b/macosx/MessageWindowController.m @@ -158,10 +158,10 @@ [fLock lock]; - NSUInteger currentCount = [fMessages count]; + NSUInteger currentIndex = [fMessages count] > 0 ? [[[fMessages lastObject] objectForKey: @"Index"] unsignedIntegerValue] : 0; NSScroller * scroller = [[fMessageTable enclosingScrollView] verticalScroller]; - const BOOL shouldScroll = currentCount == 0 || [scroller floatValue] == 1.0 || [scroller isHidden] + const BOOL shouldScroll = currentIndex == 0 || [scroller floatValue] == 1.0 || [scroller isHidden] || [scroller knobProportion] == 1.0; const NSInteger maxLevel = [[NSUserDefaults standardUserDefaults] integerForKey: @"MessageLevel"]; @@ -178,7 +178,7 @@ NSDictionary * message = [NSDictionary dictionaryWithObjectsAndKeys: [NSString stringWithUTF8String: currentMessage->message], @"Message", [NSDate dateWithTimeIntervalSince1970: currentMessage->when], @"Date", - [NSNumber numberWithUnsignedInteger: currentCount++], @"Index", //more accurate when sorting by date + [NSNumber numberWithUnsignedInteger: currentIndex++], @"Index", //more accurate when sorting by date [NSNumber numberWithInteger: currentMessage->level], @"Level", name, @"Name", file, @"File", nil]; @@ -192,9 +192,9 @@ } } - if (currentCount > TR_MAX_MSG_LOG) + if ([fMessages count] > TR_MAX_MSG_LOG) { - NSIndexSet * removeIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, currentCount-TR_MAX_MSG_LOG)]; + NSIndexSet * removeIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fMessages count]-TR_MAX_MSG_LOG)]; NSArray * itemsToRemove = [fMessages objectsAtIndexes: removeIndexes]; [fMessages removeObjectsAtIndexes: removeIndexes];