Fix race condition, which could lock PC after running a build task.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@31707 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Wolfgang Lux 2010-12-04 09:35:33 +00:00
parent 84dc841e64
commit 615124400c
2 changed files with 24 additions and 23 deletions

View file

@ -1,3 +1,9 @@
2010-12-04 Wolfgang Lux <wolfgang.lux@gmail.com>
* Framework/PCProjectBuilder.m (-build:, -logStdOut:, -logErrOut:):
Fix race condition, which could lock PC after running a build
task.
2010-12-04 Wolfgang Lux <wolfgang.lux@gmail.com>
* Framework/PCProjectManager.m (-newProject):

View file

@ -561,25 +561,11 @@
}
// Prepearing to building
_isLogging = YES;
stdOutPipe = [[NSPipe alloc] init];
stdOutHandle = [stdOutPipe fileHandleForReading];
[stdOutHandle waitForDataInBackgroundAndNotify];
[NOTIFICATION_CENTER addObserver:self
selector:@selector(logStdOut:)
name:NSFileHandleDataAvailableNotification
object:stdOutHandle];
_isErrorLogging = YES;
stdErrorPipe = [[NSPipe alloc] init];
stdErrorHandle = [stdErrorPipe fileHandleForReading];
[stdErrorHandle waitForDataInBackgroundAndNotify];
[NOTIFICATION_CENTER addObserver:self
selector:@selector(logErrOut:)
name:NSFileHandleDataAvailableNotification
object:stdErrorHandle];
[errorsCountField setStringValue:[NSString stringWithString:@""]];
errorsCount = 0;
@ -612,6 +598,21 @@
NS_DURING
{
[makeTask launch];
// now that we know that the task is running start logging
[stdOutHandle waitForDataInBackgroundAndNotify];
[NOTIFICATION_CENTER addObserver:self
selector:@selector(logStdOut:)
name:NSFileHandleDataAvailableNotification
object:stdOutHandle];
_isLogging = YES;
[stdErrorHandle waitForDataInBackgroundAndNotify];
[NOTIFICATION_CENTER addObserver:self
selector:@selector(logErrOut:)
name:NSFileHandleDataAvailableNotification
object:stdErrorHandle];
_isErrorLogging = YES;
}
NS_HANDLER
{
@ -620,7 +621,7 @@
@"OK", nil, nil, nil);
//Clean up after task is terminated
[[NSNotificationCenter defaultCenter]
[NOTIFICATION_CENTER
postNotificationName:NSTaskDidTerminateNotification
object:makeTask];
}
@ -766,14 +767,11 @@
if ((data = [stdOutHandle availableData]) && [data length] > 0)
{
[self logData:data error:NO];
}
if (makeTask)
{
[stdOutHandle waitForDataInBackgroundAndNotify];
}
else
{
// stop logging after the task has closed the pipe
[NOTIFICATION_CENTER removeObserver:self
name:NSFileHandleDataAvailableNotification
object:stdOutHandle];
@ -788,14 +786,11 @@
if ((data = [stdErrorHandle availableData]) && [data length] > 0)
{
[self logData:data error:YES];
}
if (makeTask)
{
[stdErrorHandle waitForDataInBackgroundAndNotify];
}
else
{
// stop logging after the task has closed the pipe
[NOTIFICATION_CENTER removeObserver:self
name:NSFileHandleDataAvailableNotification
object:stdErrorHandle];