Joseph Heenan
Committed by Ben Copsey

Add a new "finished" field, which is used so that KVO notifcations for isFinishe…

…d are only sent at the point when finished is actually changed.

Also only send notifications for isExecuting if it has changed state. (markAsFinished can be called more than once for cancelled requests)
... ... @@ -153,6 +153,9 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
// When the request fails or completes successfully, complete will be true
BOOL complete;
// external "finished" indicator, subject of KVO notifications; updates after 'complete'
BOOL finished;
// If an error occurs, error will contain an NSError
// If error code is = ASIConnectionFailureErrorType (1, Connection failure occurred) - inspect [[error userInfo] objectForKey:NSUnderlyingErrorKey] for more information
NSError *error;
... ...
... ... @@ -604,7 +604,7 @@ static NSOperationQueue *sharedQueue = nil;
- (BOOL)isFinished
{
return [self complete];
return finished;
}
- (BOOL)isExecuting {
... ... @@ -2822,13 +2822,22 @@ static NSOperationQueue *sharedQueue = nil;
CFMakeCollectable(proxyAuthentication);
}
[self willChangeValueForKey:@"isFinished"];
[self willChangeValueForKey:@"isExecuting"];
BOOL wasInProgress = inProgress;
BOOL wasFinished = finished;
if (!wasFinished)
[self willChangeValueForKey:@"isFinished"];
if (wasInProgress)
[self willChangeValueForKey:@"isExecuting"];
[self setInProgress:NO];
[self setStatusTimer:nil];
finished = YES;
[self didChangeValueForKey:@"isExecuting"];
[self didChangeValueForKey:@"isFinished"];
if (wasInProgress)
[self didChangeValueForKey:@"isExecuting"];
if (!wasFinished)
[self didChangeValueForKey:@"isFinished"];
CFRunLoopStop(CFRunLoopGetCurrent());
... ...