Skip to content

Commit b94f56a

Browse files
committed
Before remove 7x trials
1 parent a3fa021 commit b94f56a

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

SSYTasker.m

+31-13
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,9 @@ @implementation SSYTasker
104104
@synthesize error = m_error ;
105105
@synthesize delegate = m_delegate ;
106106

107-
- (void)processNote:(NSNotification*)note
108-
pipeName:(NSString*)pipeName
109-
intoData:(NSMutableData *)mutableData {
110-
NSFileHandle* fileHandle = (NSFileHandle*)[note object] ;
107+
- (void)eatFromFilehandle:(NSFileHandle*)fileHandle
108+
pipeName:(NSString*)pipeName
109+
intoData:(NSMutableData *)mutableData {
111110
NSError* error = nil ;
112111
NSData* data = [fileHandle availableDataError_p:&error] ;
113112
if (error) {
@@ -132,28 +131,38 @@ - (void)processNote:(NSNotification*)note
132131
}
133132
}
134133

135-
- (void)eatStdoutNote:(NSNotification*)note {
134+
- (void)eatStdoutFromFileHandle:(NSFileHandle *)fileHandle {
136135
NSMutableData* mutableData = [self stdoutData] ;
137136
if (!mutableData) {
138137
mutableData = [[NSMutableData alloc] init] ;
139138
[self setStdoutData:mutableData] ;
140139
}
141140

142-
[self processNote:note
143-
pipeName:@"stdout"
144-
intoData:mutableData];
141+
[self eatFromFilehandle:fileHandle
142+
pipeName:@"stdout"
143+
intoData:mutableData] ;
145144
}
146145

147-
- (void)eatStderrNote:(NSNotification*)note {
146+
- (void)eatStdoutNote:(NSNotification*)note {
147+
NSFileHandle* fileHandle = [note object] ;
148+
[self eatStdoutFromFileHandle:fileHandle] ;
149+
}
150+
151+
- (void)eatStderrFromFileHandle:(NSFileHandle *)fileHandle {
148152
NSMutableData* mutableData = [self stderrData] ;
149153
if (!mutableData) {
150154
mutableData = [[NSMutableData alloc] init] ;
151155
[self setStderrData:mutableData] ;
152156
}
153157

154-
[self processNote:note
155-
pipeName:@"stderr"
156-
intoData:mutableData];
158+
[self eatFromFilehandle:fileHandle
159+
pipeName:@"stderr"
160+
intoData:mutableData];
161+
}
162+
163+
- (void)eatStderrNote:(NSNotification*)note {
164+
NSFileHandle* fileHandle = [note object] ;
165+
[self eatStderrFromFileHandle:fileHandle];
157166
}
158167

159168
- (void)taskTerminatedNote:(NSNotification*)note {
@@ -282,7 +291,7 @@ - (NSInteger)runCommand:(NSString*)launchPath
282291
BOOL keepRunning = [runLoop runMode:NSDefaultRunLoopMode
283292
beforeDate:[NSDate distantFuture]] ;
284293
if (!keepRunning) {
285-
[self setIsTaskDone:YES] ;
294+
[self setIsTaskDone:YES] ;
286295
}
287296
// That's all. Actual work is done by notification handlers.
288297
// Just run the loop again, to wait for next notification or done.
@@ -293,6 +302,15 @@ - (NSInteger)runCommand:(NSString*)launchPath
293302

294303
exitStatus = [task terminationStatus] ;
295304

305+
// Added the following to fix bug, 20130712, which caused stderr or
306+
// stdout to be not returned about 0.5% of the time. Apparently there
307+
// is some kind of race condition wherein an NSTask can terminate
308+
// before the final notification of available stdout or stderr has
309+
// been processed, or something like that. Anyhow, it took me two days
310+
// to figure this out. This fixed it…
311+
[self eatStdoutFromFileHandle:fileStdout] ;
312+
[self eatStderrFromFileHandle:fileStderr] ;
313+
296314
[[NSNotificationCenter defaultCenter] removeObserver:self] ;
297315
}
298316

SSYTokenField.m

-2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,9 @@ - (void)sizeHeightToFit {
9090
if (nRows == 1) {
9191
// This would only happen if the first token by itself was too wide
9292
// to fit in a row, which would be very rare
93-
/*SSYDBL*/ NSLog(@"My fix 1") ;
9493
height += (tokenHeight + 2 * interrowSpace) ;
9594
}
9695
else {
97-
/*SSYDBL*/ NSLog(@"My fix 2") ;
9896
height += (tokenHeight + interrowSpace) ;
9997
}
10098

0 commit comments

Comments
 (0)