[ios, osx] Fixed crash adding mixture of points and shapes
Fixes #5096.
This commit is contained in:
committed by
Minh Nguyễn
parent
251c41f528
commit
645dd25d0b
@@ -2781,7 +2781,9 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
|
||||
if ( ! annotations) return;
|
||||
[self willChangeValueForKey:@"annotations"];
|
||||
|
||||
NSMutableArray *userPoints = [NSMutableArray array];
|
||||
std::vector<mbgl::PointAnnotation> points;
|
||||
NSMutableArray *userShapes = [NSMutableArray array];
|
||||
std::vector<mbgl::ShapeAnnotation> shapes;
|
||||
|
||||
NSMutableDictionary *annotationImagesForAnnotation = [NSMutableDictionary dictionary];
|
||||
@@ -2797,6 +2799,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
|
||||
if ([annotation isKindOfClass:[MGLMultiPoint class]])
|
||||
{
|
||||
[(MGLMultiPoint *)annotation addShapeAnnotationObjectToCollection:shapes withDelegate:self];
|
||||
[userShapes addObject:annotation];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2846,6 +2849,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
|
||||
annotationImagesForAnnotation[annotationValue] = annotationImage;
|
||||
}
|
||||
|
||||
[userPoints addObject:annotation];
|
||||
points.emplace_back(MGLLatLngFromLocationCoordinate2D(annotation.coordinate), symbolName.UTF8String ?: "");
|
||||
}
|
||||
}
|
||||
@@ -2858,7 +2862,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
|
||||
|
||||
for (size_t i = 0; i < annotationTags.size(); ++i)
|
||||
{
|
||||
id<MGLAnnotation> annotation = annotations[i];
|
||||
id<MGLAnnotation> annotation = userPoints[i];
|
||||
NSValue *annotationValue = [NSValue valueWithNonretainedObject:annotation];
|
||||
|
||||
MGLAnnotationContext context;
|
||||
@@ -2890,7 +2894,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
|
||||
for (size_t i = 0; i < annotationTags.size(); ++i)
|
||||
{
|
||||
MGLAnnotationTag annotationTag = annotationTags[i];
|
||||
id <MGLAnnotation> annotation = annotations[i];
|
||||
id <MGLAnnotation> annotation = userPoints[i];
|
||||
|
||||
MGLAnnotationContext context;
|
||||
context.annotation = annotation;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
## master
|
||||
|
||||
* Fixed an issue in which Mapbox.framework was nested inside another folder named Mapbox.framework. ([#4998](https://github.com/mapbox/mapbox-gl-native/pull/4998))
|
||||
* Fixed a crash passing a mixture of point and shape annotations into `-[MGLMapView addAnnotations:]`. ([#5097](https://github.com/mapbox/mapbox-gl-native/pull/5097))
|
||||
|
||||
## 0.1.0
|
||||
|
||||
|
||||
@@ -1603,7 +1603,9 @@ public:
|
||||
|
||||
BOOL delegateHasImagesForAnnotations = [self.delegate respondsToSelector:@selector(mapView:imageForAnnotation:)];
|
||||
|
||||
NSMutableArray *userPoints = [NSMutableArray array];
|
||||
std::vector<mbgl::PointAnnotation> points;
|
||||
NSMutableArray *userShapes = [NSMutableArray array];
|
||||
std::vector<mbgl::ShapeAnnotation> shapes;
|
||||
NSMutableArray *annotationImages = [NSMutableArray arrayWithCapacity:annotations.count];
|
||||
|
||||
@@ -1613,6 +1615,7 @@ public:
|
||||
if ([annotation isKindOfClass:[MGLMultiPoint class]]) {
|
||||
// The multipoint knows how to style itself (with the map view’s help).
|
||||
[(MGLMultiPoint *)annotation addShapeAnnotationObjectToCollection:shapes withDelegate:self];
|
||||
[userShapes addObject:annotation];
|
||||
} else {
|
||||
MGLAnnotationImage *annotationImage = nil;
|
||||
if (delegateHasImagesForAnnotations) {
|
||||
@@ -1637,6 +1640,7 @@ public:
|
||||
}
|
||||
[annotationImages addObject:annotationImage];
|
||||
|
||||
[userPoints addObject:annotation];
|
||||
points.emplace_back(MGLLatLngFromLocationCoordinate2D(annotation.coordinate), symbolName.UTF8String ?: "");
|
||||
|
||||
// Opt into potentially expensive tooltip tracking areas.
|
||||
@@ -1654,7 +1658,7 @@ public:
|
||||
MGLAnnotationTag annotationTag = annotationTags[i];
|
||||
MGLAnnotationImage *annotationImage = annotationImages[i];
|
||||
annotationImage.styleIconIdentifier = @(points[i].icon.c_str());
|
||||
id <MGLAnnotation> annotation = annotations[i];
|
||||
id <MGLAnnotation> annotation = userPoints[i];
|
||||
|
||||
MGLAnnotationContext context;
|
||||
context.annotation = annotation;
|
||||
@@ -1674,7 +1678,7 @@ public:
|
||||
|
||||
for (size_t i = 0; i < annotationTags.size(); ++i) {
|
||||
MGLAnnotationTag annotationTag = annotationTags[i];
|
||||
id <MGLAnnotation> annotation = annotations[i];
|
||||
id <MGLAnnotation> annotation = userShapes[i];
|
||||
|
||||
MGLAnnotationContext context;
|
||||
context.annotation = annotation;
|
||||
|
||||
Reference in New Issue
Block a user