mirror of
https://github.com/transmission/transmission
synced 2025-01-31 03:12:44 +00:00
fix a bug with the new message index code
This commit is contained in:
parent
9888043e13
commit
23b652d2bc
1 changed files with 5 additions and 5 deletions
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue