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)
Showing
2 changed files
with
13 additions
and
1 deletions
| @@ -153,6 +153,9 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount; | @@ -153,6 +153,9 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount; | ||
| 153 | // When the request fails or completes successfully, complete will be true | 153 | // When the request fails or completes successfully, complete will be true |
| 154 | BOOL complete; | 154 | BOOL complete; |
| 155 | 155 | ||
| 156 | + // external "finished" indicator, subject of KVO notifications; updates after 'complete' | ||
| 157 | + BOOL finished; | ||
| 158 | + | ||
| 156 | // If an error occurs, error will contain an NSError | 159 | // If an error occurs, error will contain an NSError |
| 157 | // If error code is = ASIConnectionFailureErrorType (1, Connection failure occurred) - inspect [[error userInfo] objectForKey:NSUnderlyingErrorKey] for more information | 160 | // If error code is = ASIConnectionFailureErrorType (1, Connection failure occurred) - inspect [[error userInfo] objectForKey:NSUnderlyingErrorKey] for more information |
| 158 | NSError *error; | 161 | NSError *error; |
| @@ -604,7 +604,7 @@ static NSOperationQueue *sharedQueue = nil; | @@ -604,7 +604,7 @@ static NSOperationQueue *sharedQueue = nil; | ||
| 604 | 604 | ||
| 605 | - (BOOL)isFinished | 605 | - (BOOL)isFinished |
| 606 | { | 606 | { |
| 607 | - return [self complete]; | 607 | + return finished; |
| 608 | } | 608 | } |
| 609 | 609 | ||
| 610 | - (BOOL)isExecuting { | 610 | - (BOOL)isExecuting { |
| @@ -2822,12 +2822,21 @@ static NSOperationQueue *sharedQueue = nil; | @@ -2822,12 +2822,21 @@ static NSOperationQueue *sharedQueue = nil; | ||
| 2822 | CFMakeCollectable(proxyAuthentication); | 2822 | CFMakeCollectable(proxyAuthentication); |
| 2823 | } | 2823 | } |
| 2824 | 2824 | ||
| 2825 | + BOOL wasInProgress = inProgress; | ||
| 2826 | + BOOL wasFinished = finished; | ||
| 2827 | + | ||
| 2828 | + if (!wasFinished) | ||
| 2825 | [self willChangeValueForKey:@"isFinished"]; | 2829 | [self willChangeValueForKey:@"isFinished"]; |
| 2830 | + if (wasInProgress) | ||
| 2826 | [self willChangeValueForKey:@"isExecuting"]; | 2831 | [self willChangeValueForKey:@"isExecuting"]; |
| 2832 | + | ||
| 2827 | [self setInProgress:NO]; | 2833 | [self setInProgress:NO]; |
| 2828 | [self setStatusTimer:nil]; | 2834 | [self setStatusTimer:nil]; |
| 2835 | + finished = YES; | ||
| 2829 | 2836 | ||
| 2837 | + if (wasInProgress) | ||
| 2830 | [self didChangeValueForKey:@"isExecuting"]; | 2838 | [self didChangeValueForKey:@"isExecuting"]; |
| 2839 | + if (!wasFinished) | ||
| 2831 | [self didChangeValueForKey:@"isFinished"]; | 2840 | [self didChangeValueForKey:@"isFinished"]; |
| 2832 | 2841 | ||
| 2833 | CFRunLoopStop(CFRunLoopGetCurrent()); | 2842 | CFRunLoopStop(CFRunLoopGetCurrent()); |
-
Please register or login to post a comment