]> granicus.if.org Git - transmission/commitdiff
slightly better locking in the file table
authorMitchell Livingston <livings124@transmissionbt.com>
Sat, 30 Jul 2011 00:11:29 +0000 (00:11 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Sat, 30 Jul 2011 00:11:29 +0000 (00:11 +0000)
macosx/FileOutlineController.h
macosx/FileOutlineController.m

index 0f61988b63e3c53fd9da95d099514ec060e7e917..473e5d9b3515d874870fbbbf9b400e4432bf0e0c 100644 (file)
@@ -36,7 +36,7 @@
     
     NSString * fFilterText;
     
-    NSLock * fLock;
+    NSRecursiveLock * fLock;
 }
 
 - (FileOutlineView *) outlineView;
index 0078e6a189d2dfa23f19ee32333b8b7908b7bff2..e00ac5e6f81ae172db3780b349523edd508e7ece 100644 (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