1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-15 16:29:34 +00:00

slightly better locking in the file table

This commit is contained in:
Mitchell Livingston 2011-07-30 00:11:29 +00:00
parent 2d5d902175
commit b0659bacf9
2 changed files with 17 additions and 7 deletions

View file

@ -36,7 +36,7 @@
NSString * fFilterText;
NSLock * fLock;
NSRecursiveLock * fLock;
}
- (FileOutlineView *) outlineView;

View file

@ -70,7 +70,7 @@ typedef enum
[fOutline setMenu: [self menu]];
#warning needed?
fLock = [[NSLock alloc] init];
fLock = [[NSRecursiveLock alloc] init];
[self setTorrent: nil];
}
@ -109,21 +109,25 @@ typedef enum
- (void) setFilterText: (NSString *) text
{
[fLock lock];
if ([text isEqualToString: @""])
text = nil;
if ((!text && !fFilterText) || (text && fFilterText && [text isEqualToString: fFilterText]))
{
[fLock unlock];
return;
}
const BOOL onLion = [NSApp isOnLionOrBetter];
[fLock lock];
if (onLion)
{
[[NSAnimationContext currentContext] setCompletionHandler: ^{ [fLock unlock]; NSLog(@"called"); }];
[NSAnimationContext beginGrouping];
[fOutline beginUpdates];
}
NSUInteger currentIndex = 0, totalCount = 0;
NSMutableArray * itemsToAdd = [NSMutableArray array];
@ -200,14 +204,20 @@ typedef enum
[fOutline insertItemsAtIndexes: itemsToAddIndexes inParent: nil withAnimation: NSTableViewAnimationSlideUp];
if (onLion)
{
[fOutline endUpdates];
[NSAnimationContext endGrouping];
}
else
{
[fOutline reloadData];
[fLock unlock];
}
[fFilterText release];
fFilterText = [text retain];
[fLock unlock];
}
- (void) reloadData