From: Mitchell Livingston Date: Mon, 1 Aug 2011 22:27:21 +0000 (+0000) Subject: more experimenting with locking in the files table X-Git-Tag: 2.40b1~297 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97cd1d9d054b5f36a4f2889c65ee72b19c60c5ae;p=transmission more experimenting with locking in the files table --- diff --git a/macosx/FileOutlineController.m b/macosx/FileOutlineController.m index e00ac5e6f..76c589a6d 100644 --- a/macosx/FileOutlineController.m +++ b/macosx/FileOutlineController.m @@ -31,6 +31,8 @@ #import "NSMutableArrayAdditions.h" #import +#import "utils.h" + #define ROW_SMALL_HEIGHT 18.0 typedef enum @@ -69,8 +71,8 @@ typedef enum [fOutline setMenu: [self menu]]; - #warning needed? fLock = [[NSRecursiveLock alloc] init]; + [fLock setName: @"File Table"]; [self setTorrent: nil]; } @@ -99,7 +101,8 @@ typedef enum [fFilterText release]; fFilterText = nil; - [fLock lock]; + while (![fLock tryLock]) + tr_wait_msec(100); [fOutline deselectAll: nil]; [fOutline reloadData]; @@ -119,11 +122,12 @@ typedef enum const BOOL onLion = [NSApp isOnLionOrBetter]; - [fLock lock]; + while (![fLock tryLock]) + tr_wait_msec(100); if (onLion) { - [[NSAnimationContext currentContext] setCompletionHandler: ^{ [fLock unlock]; NSLog(@"called"); }]; + [[NSAnimationContext currentContext] setCompletionHandler: ^{ [fLock unlock]; }]; [NSAnimationContext beginGrouping]; [fOutline beginUpdates]; @@ -224,7 +228,8 @@ typedef enum { [fTorrent updateFileStat]; - [fLock lock]; + while (![fLock tryLock]) + tr_wait_msec(100); [fOutline reloadData]; @@ -367,7 +372,8 @@ typedef enum - (void) setCheck: (id) sender { - [fLock lock]; + while (![fLock tryLock]) + tr_wait_msec(100); NSInteger state = [sender tag] == FILE_UNCHECK_TAG ? NSOffState : NSOnState; @@ -384,7 +390,8 @@ typedef enum - (void) setOnlySelectedCheck: (id) sender { - [fLock lock]; + while (![fLock tryLock]) + tr_wait_msec(100); NSIndexSet * indexSet = [fOutline selectedRowIndexes]; NSMutableIndexSet * itemIndexes = [NSMutableIndexSet indexSet]; @@ -417,7 +424,8 @@ typedef enum priority = TR_PRI_LOW; } - [fLock lock]; + while (![fLock tryLock]) + tr_wait_msec(100); NSIndexSet * indexSet = [fOutline selectedRowIndexes]; NSMutableIndexSet * itemIndexes = [NSMutableIndexSet indexSet]; @@ -432,7 +440,8 @@ typedef enum - (void) revealFile: (id) sender { - [fLock lock]; + while (![fLock tryLock]) + tr_wait_msec(100); NSIndexSet * indexes = [fOutline selectedRowIndexes]; if ([NSApp isOnSnowLeopardOrBetter])