mirror of
https://github.com/transmission/transmission.git
synced 2026-04-17 23:54:19 +01:00
add a lock to the message lock code
This commit is contained in:
@@ -36,6 +36,8 @@
|
||||
NSDictionary * fAttributes;
|
||||
|
||||
NSTimer * fTimer;
|
||||
|
||||
NSLock * fLock;
|
||||
}
|
||||
|
||||
- (void) updateLog: (NSTimer *) timer;
|
||||
|
||||
@@ -50,6 +50,8 @@
|
||||
- (void) dealloc
|
||||
{
|
||||
[fTimer invalidate];
|
||||
[fLock release];
|
||||
|
||||
[fMessages release];
|
||||
[fDisplayedMessages release];
|
||||
|
||||
@@ -123,6 +125,8 @@
|
||||
|
||||
fMessages = [[NSMutableArray alloc] init];
|
||||
fDisplayedMessages = [[NSMutableArray alloc] init];
|
||||
|
||||
fLock = [[NSLock alloc] init];
|
||||
}
|
||||
|
||||
- (void) windowDidBecomeKey: (NSNotification *) notification
|
||||
@@ -147,6 +151,8 @@
|
||||
|
||||
static NSUInteger currentIndex = 0;
|
||||
|
||||
[fLock lock];
|
||||
|
||||
NSScroller * scroller = [[fMessageTable enclosingScrollView] verticalScroller];
|
||||
const BOOL shouldScroll = currentIndex == 0 || [scroller floatValue] == 1.0 || [scroller isHidden]
|
||||
|| [scroller knobProportion] == 1.0;
|
||||
@@ -189,6 +195,8 @@
|
||||
if (shouldScroll)
|
||||
[fMessageTable scrollRowToVisible: [fDisplayedMessages count]-1];
|
||||
}
|
||||
|
||||
[fLock unlock];
|
||||
}
|
||||
|
||||
- (NSInteger) numberOfRowsInTableView: (NSTableView *) tableView
|
||||
@@ -303,6 +311,8 @@
|
||||
if ([[NSUserDefaults standardUserDefaults] integerForKey: @"MessageLevel"] == level)
|
||||
return;
|
||||
|
||||
[fLock lock];
|
||||
|
||||
[[NSUserDefaults standardUserDefaults] setInteger: level forKey: @"MessageLevel"];
|
||||
|
||||
if (level == TR_MSG_DBG) //all messages at this level
|
||||
@@ -319,6 +329,8 @@
|
||||
|
||||
[fMessageTable deselectAll: nil];
|
||||
[fMessageTable reloadData];
|
||||
|
||||
[fLock unlock];
|
||||
}
|
||||
|
||||
- (void) clearLog: (id) sender
|
||||
|
||||
Reference in New Issue
Block a user