add a lock to the message lock code

This commit is contained in:
Mitchell Livingston
2009-11-28 21:01:27 +00:00
parent b9ef88e898
commit 94f110e314
2 changed files with 14 additions and 0 deletions

View File

@@ -36,6 +36,8 @@
NSDictionary * fAttributes;
NSTimer * fTimer;
NSLock * fLock;
}
- (void) updateLog: (NSTimer *) timer;

View File

@@ -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