Skip to content

Commit 8cf4935

Browse files
authored
Merge pull request #264 from wangliangliang2/master
fix delegate sometimes not release
2 parents c42fdd9 + 3d18254 commit 8cf4935

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

QiniuSDK/Http/QNSessionManager.m

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,6 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task
5858
if (_cancelBlock && _cancelBlock()) {
5959
[_task cancel];
6060
}
61-
62-
float progress = (float)totalBytesSent / totalBytesExpectedToSend;
63-
if (progress == 1.0f) {
64-
self.task = nil;
65-
self.cancelBlock = nil;
66-
self.progressBlock = nil;
67-
}
6861
}
6962

7063
@end
@@ -203,7 +196,7 @@ - (void)sendRequest2:(NSMutableURLRequest *)request
203196
QNInternalProgressBlock progressBlock2 = ^(long long totalBytesWritten, long long totalBytesExpectedToWrite) {
204197
progressBlock(totalBytesWritten, totalBytesExpectedToWrite);
205198
};
206-
QNProgessDelegate *delegate = (QNProgessDelegate *)_httpManager.delegate;
199+
__block QNProgessDelegate *delegate = (QNProgessDelegate *)_httpManager.delegate;
207200
delegate.progressBlock = progressBlock2;
208201
NSURLSessionUploadTask *uploadTask = [_httpManager uploadTaskWithRequest:request fromData:nil completionHandler:^(NSData *_Nullable data, NSURLResponse *_Nullable response, NSError *_Nullable error) {
209202

@@ -224,6 +217,9 @@ - (void)sendRequest2:(NSMutableURLRequest *)request
224217
} else {
225218
info = [QNSessionManager buildResponseInfo:httpResponse withError:error withDuration:duration withResponse:data withHost:domain withIp:ip];
226219
}
220+
delegate.task = nil;
221+
delegate.cancelBlock = nil;
222+
delegate.progressBlock = nil;
227223
completeBlock(info, resp);
228224
}];
229225
delegate.task = uploadTask;

QiniuSDKTests/QNFileRecorderTest.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ - (void) template:(int)size pos:(float)pos {
8282
if (percent < pos - 256.0 / size) {
8383
failed = YES;
8484
}
85-
NSLog(@"continue progress %f", percent);
85+
NSLog(@"continue progress %f,%f", percent,pos - 256.0 / size);
8686
}
8787
params:nil
8888
checkCrc:NO
@@ -92,6 +92,7 @@ - (void) template:(int)size pos:(float)pos {
9292
info = i;
9393
}
9494
option:opt];
95+
NSLog(@"failed: %@",failed ? @"YES" : @"NO");
9596
AGWW_WAIT_WHILE(key == nil, 60 * 30);
9697
NSLog(@"info %@", info);
9798
XCTAssert(info.isOK, @"Pass");
@@ -132,7 +133,7 @@ - (void)test8M {
132133
if (_inTravis) {
133134
return;
134135
}
135-
[self template:8 * 1024 + 1 pos:0.8];
136+
[self template:8 * 1024 + 1 pos:0.7];
136137
}
137138

138139
//#endif

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
通过 CocoaPods
1414

1515
```ruby
16-
pod "Qiniu", "~> 7.2"
16+
pod "Qiniu", "~> 7.2"
1717
```
1818

1919
## 运行环境
2020

2121
| Qiniu SDK 版本 | 最低 iOS版本 | 最低 OS X 版本 | Notes |
2222
| :--------------------------------------: | :------: | :--------: | :-----------: |
23-
| 7.2.x | iOS 7 | OS X 10.9 | Xcode 最低版本 6. |
23+
| 7.2.x | iOS 7 | OS X 10.9 | Xcode 最低版本 6. |
2424
| 7.1.x / AFNetworking-3.x | iOS 7 | OS X 10.9 | Xcode 最低版本 6. |
2525
| [7.0.x / AFNetworking-2.x](https://github.com/qiniu/objc-sdk/tree/7.0.x/AFNetworking-2.x) | iOS 6 | OS X 10.8 | Xcode 最低版本 5. |
2626
| [7.x / AFNetworking-1.x](https://github.com/qiniu/objc-sdk/tree/AFNetworking-1.x) | iOS 5 | OS X 10.7 | Xcode 最低版本 5. |

0 commit comments

Comments
 (0)