Cause a failure when an operation is cancelled, fixes #657
This commit is contained in:
parent
a146a3bf66
commit
7134e9612f
6 changed files with 11 additions and 28 deletions
|
|
@ -273,10 +273,6 @@ static void AFSwizzleClassMethodWithClassAndSelectorUsingBlock(Class klass, SEL
|
|||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-retain-cycles"
|
||||
self.completionBlock = ^{
|
||||
if ([self isCancelled]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.error) {
|
||||
if (failure) {
|
||||
dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{
|
||||
|
|
|
|||
|
|
@ -203,10 +203,6 @@ static dispatch_queue_t image_request_operation_processing_queue() {
|
|||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-retain-cycles"
|
||||
self.completionBlock = ^ {
|
||||
if ([self isCancelled]) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch_async(image_request_operation_processing_queue(), ^(void) {
|
||||
if (self.error) {
|
||||
if (failure) {
|
||||
|
|
|
|||
|
|
@ -104,11 +104,7 @@ static dispatch_queue_t json_request_operation_processing_queue() {
|
|||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-retain-cycles"
|
||||
self.completionBlock = ^ {
|
||||
if ([self isCancelled]) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.completionBlock = ^ {
|
||||
if (self.error) {
|
||||
if (failure) {
|
||||
dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{
|
||||
|
|
|
|||
|
|
@ -108,11 +108,7 @@ static dispatch_queue_t property_list_request_operation_processing_queue() {
|
|||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-retain-cycles"
|
||||
self.completionBlock = ^ {
|
||||
if ([self isCancelled]) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.completionBlock = ^ {
|
||||
if (self.error) {
|
||||
if (failure) {
|
||||
dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{
|
||||
|
|
|
|||
|
|
@ -453,15 +453,18 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
|
|||
}
|
||||
|
||||
- (void)cancelConnection {
|
||||
|
||||
NSDictionary *userInfo = nil;
|
||||
if ([self.request URL]) {
|
||||
userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey];
|
||||
}
|
||||
self.error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo];
|
||||
|
||||
if (self.connection) {
|
||||
[self.connection cancel];
|
||||
|
||||
// Manually send this delegate message since `[self.connection cancel]` causes the connection to never send another message to its delegate
|
||||
NSDictionary *userInfo = nil;
|
||||
if ([self.request URL]) {
|
||||
userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey];
|
||||
}
|
||||
[self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo]];
|
||||
[self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:self.error];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -140,11 +140,7 @@ static dispatch_queue_t xml_request_operation_processing_queue() {
|
|||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-retain-cycles"
|
||||
self.completionBlock = ^ {
|
||||
if ([self isCancelled]) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.completionBlock = ^ {
|
||||
dispatch_async(xml_request_operation_processing_queue(), ^(void) {
|
||||
NSXMLParser *XMLParser = self.responseXMLParser;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue