diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-06-07 14:14:41 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-06-07 14:14:41 -0700 |
commit | e503f9279fd1079e12772c6a9d8b8d4ee64a53f3 (patch) | |
tree | c0c2235dc618b3dbbc8b145a58f375a5e6b3ebbc /platform/ios/src/MGLMapView.mm | |
parent | 9746f76744b16cd3dd883eb85552ce8b260df2e1 (diff) | |
download | qtlocation-mapboxgl-e503f9279fd1079e12772c6a9d8b8d4ee64a53f3.tar.gz |
Fix crash in userLocationVerticalAlignment, analyzer warning (#5278)
* [ios] Fixed crash in userLocationVerticalAlignment
Avoid creating an array with nil.
Fixes #5274.
* [ios] Fixed analyzer warning
Fixed a write-without-read analyzer warning introduced in #5235.
Diffstat (limited to 'platform/ios/src/MGLMapView.mm')
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index bd8762c475..5d1bcb1109 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -2103,8 +2103,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) } std::sort(visibleAnnotations.begin(), visibleAnnotations.end()); - auto foundElement = std::find(visibleAnnotations.begin(), visibleAnnotations.end(), - ((MGLAnnotationAccessibilityElement *)element).tag); + auto foundElement = std::find(visibleAnnotations.begin(), visibleAnnotations.end(), tag); if (foundElement == visibleAnnotations.end()) { return NSNotFound; @@ -3846,9 +3845,10 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) [self.locationManager stopUpdatingHeading]; - if (self.userLocationAnnotationView) + CLLocation *location = self.userLocation.location; + if (location && self.userLocationAnnotationView) { - [self locationManager:self.locationManager didUpdateLocations:@[self.userLocation.location] animated:animated]; + [self locationManager:self.locationManager didUpdateLocations:@[location] animated:animated]; } break; @@ -3896,7 +3896,11 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) _userLocationVerticalAlignment = alignment; if (self.userTrackingMode != MGLUserTrackingModeNone) { - [self locationManager:self.locationManager didUpdateLocations:@[self.userLocation.location] animated:animated]; + CLLocation *location = self.userLocation.location; + if (location) + { + [self locationManager:self.locationManager didUpdateLocations:@[location] animated:animated]; + } } } |