diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2017-08-03 14:06:58 -0400 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2017-08-03 14:06:58 -0400 |
commit | 38dda0f215c2a9a7324159b1ed59487317c30791 (patch) | |
tree | fd7fec5d50399564795fd92cd87d32bd4c0c7fae /SmartDeviceLink/SDLProxy.m | |
parent | 7b7aa3da1b60acd79f5f7a98eab5e1d62ae866a9 (diff) | |
parent | 588dd453432b4102f6ddadf365c6bd73f161cedb (diff) | |
download | sdl_ios-38dda0f215c2a9a7324159b1ed59487317c30791.tar.gz |
Merge branch 'bugs/issue_665_url_request_crashes' into release/5.0.0
# Conflicts:
# SmartDeviceLink/SDLProxy.m
# SmartDeviceLink/SDLTouchType.h
# SmartDeviceLink/SDLTouchType.m
# SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTouchTypeSpec.m
Diffstat (limited to 'SmartDeviceLink/SDLProxy.m')
-rw-r--r-- | SmartDeviceLink/SDLProxy.m | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/SmartDeviceLink/SDLProxy.m b/SmartDeviceLink/SDLProxy.m index b6a7461b1..a86d57980 100644 --- a/SmartDeviceLink/SDLProxy.m +++ b/SmartDeviceLink/SDLProxy.m @@ -451,9 +451,12 @@ static float DefaultConnectionTimeout = 45.0; } // Send the HTTP Request + __weak typeof(self) weakSelf = self; [self uploadForBodyDataDictionary:JSONDictionary URLString:request.url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + __strong typeof(weakSelf) strongSelf = weakSelf; + if (error) { SDLLogW(@"OnSystemRequest HTTP response error: %@", error); return; @@ -480,20 +483,22 @@ static float DefaultConnectionTimeout = 45.0; } // Send the RPC Request - [self sendRPC:request]; + [strongSelf sendRPC:request]; }]; } - (void)handleSystemRequestLockScreenIconURL:(SDLOnSystemRequest *)request { + __weak typeof(self) weakSelf = self; [self sdl_sendDataTaskWithURL:[NSURL URLWithString:request.url] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + __strong typeof(weakSelf) strongSelf = weakSelf; if (error != nil) { SDLLogW(@"OnSystemRequest (lock screen icon) HTTP download task failed: %@", error.localizedDescription); return; } UIImage *icon = [UIImage imageWithData:data]; - [self invokeMethodOnDelegates:@selector(onReceivedLockScreenIcon:) withObject:icon]; + [strongSelf invokeMethodOnDelegates:@selector(onReceivedLockScreenIcon:) withObject:icon]; }]; } @@ -503,9 +508,11 @@ static float DefaultConnectionTimeout = 45.0; return; } + __weak typeof(self) weakSelf = self; [self sdl_uploadData:request.bulkData toURLString:request.url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + __strong typeof(weakSelf) strongSelf = weakSelf; if (error != nil) { SDLLogW(@"OnSystemRequest (HTTP) error: %@", error.localizedDescription); return; @@ -527,7 +534,7 @@ static float DefaultConnectionTimeout = 45.0; putFile.bulkData = data; // Send RPC Request - [self sendRPC:putFile]; + [strongSelf sendRPC:putFile]; }]; } @@ -686,10 +693,11 @@ static float DefaultConnectionTimeout = 45.0; } // Send the HTTP Request + __weak typeof(self) weakSelf = self; [[self.urlSession uploadTaskWithRequest:request fromData:data completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { - [self syncPDataNetworkRequestCompleteWithData:data response:response error:error]; + [weakSelf syncPDataNetworkRequestCompleteWithData:data response:response error:error]; }] resume]; SDLLogV(@"OnEncodedSyncPData (HTTP Request)"); |