summaryrefslogtreecommitdiff
path: root/platform/darwin/src/http_file_source.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin/src/http_file_source.mm')
-rw-r--r--platform/darwin/src/http_file_source.mm4
1 files changed, 3 insertions, 1 deletions
diff --git a/platform/darwin/src/http_file_source.mm b/platform/darwin/src/http_file_source.mm
index 5c4a9c1b82..1b5a67ea5d 100644
--- a/platform/darwin/src/http_file_source.mm
+++ b/platform/darwin/src/http_file_source.mm
@@ -250,7 +250,7 @@ std::unique_ptr<AsyncRequest> HTTPFileSource::request(const Resource& resource,
[MGLNativeNetworkManager.sharedManager startDownloadEvent:url.relativePath type:@"tile"];
}
- NSURLSession *session;
+ __block NSURLSession *session;
// Use the delegate's session if there is one, otherwise use the one that
// was created when this class was constructed.
@@ -268,6 +268,8 @@ std::unique_ptr<AsyncRequest> HTTPFileSource::request(const Resource& resource,
request->task = [session
dataTaskWithRequest:req
completionHandler:^(NSData* data, NSURLResponse* res, NSError* error) {
+ session = nil;
+
if (error && [error code] == NSURLErrorCancelled) {
[MGLNativeNetworkManager.sharedManager cancelDownloadEventForResponse:res];
return;