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.
This commit is contained in:
Minh Nguyễn
2016-06-07 14:14:41 -07:00
parent 9746f76744
commit e503f9279f
2 changed files with 10 additions and 5 deletions

View File

@@ -21,6 +21,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CON
- Fixed an issue preventing KVO change notifications from being generated on MGLMapView’s `userTrackingMode` key path when `-setUserTrackingMode:animated:` is called. ([#4724](https://github.com/mapbox/mapbox-gl-native/pull/4724))
- Rendering now occurs on the main thread, fixing a hang when calling `-[MGLMapView styleURL]` before the map view has fully loaded or while the application is in the background. ([#2909](https://github.com/mapbox/mapbox-gl-native/pull/2909))
- Improved responsiveness when zooming in then immediately panning around. ([#4595](https://github.com/mapbox/mapbox-gl-native/pull/4595))
- Fixed a crash setting MGLMapView’s `userLocationVerticalAlignment` property before a user location update has occurred. ([#5274](https://github.com/mapbox/mapbox-gl-native/issues/5274))
- Added category methods on NSValue for converting to and from the structure types defined in MGLGeometry.h. ([#4802](https://github.com/mapbox/mapbox-gl-native/pull/4802))
- Added NSFormatter subclasses for converting geographic coordinates and directions into display strings. ([#4802](https://github.com/mapbox/mapbox-gl-native/pull/4802))
- Added a new method, `-[MGLMapView cameraThatFitsCoordinateBounds:]`, to get a camera that you can pass into `-setCamera:` that fits the given coordinate bounds. ([#4790](https://github.com/mapbox/mapbox-gl-native/pull/4790))

View File

@@ -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];
}
}
}