Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[ios] assertion to check if an annotationTag > 0 - #8588

Merged
fabian-guerra merged 2 commits into
release-ios-v3.5.0-android-v5.0.0from
fabian-visible-annotations-assert
Apr 5, 2017
Merged

fabian-guerra merged 2 commits into
release-ios-v3.5.0-android-v5.0.0from
fabian-visible-annotations-assert

Conversation

@fabian-guerra

Copy link
Copy Markdown
Contributor

Addresses #8163 (comment)

@fabian-guerra
fabian-guerra requested a review from 1ec5 March 30, 2017 20:28
@fabian-guerra fabian-guerra self-assigned this Mar 30, 2017
@fabian-guerra fabian-guerra added this to the ios-v3.6.0 milestone Mar 30, 2017
@fabian-guerra fabian-guerra added the iOS Mapbox Maps SDK for iOS label Mar 30, 2017
Comment thread platform/ios/src/MGLMapView.mm Outdated
continue;
}
MGLAnnotationContext annotationContext = _annotationContextsByAnnotationTag.at(annotationTag);
NSAssert(_annotationContextsByAnnotationTag.count(annotationTag), @"Missing annotation for tag %u.", annotationTag);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion checks whether there’s an entry for annotationTag in _annotationContextsByAnnotationTag. There’s no way this assertion can fail, because we already have a guard a few lines above that continues in that case. Instead, here, we need to assert that annotationContext.annotation is non-nil.

@fabian-guerra
fabian-guerra force-pushed the fabian-visible-annotations-assert branch from 40fa216 to 15d0e77 Compare April 3, 2017 13:59
@boundsj boundsj modified the milestones: ios-v3.5.1, ios-v3.6.0 Apr 3, 2017
Comment thread platform/ios/src/MGLMapView.mm Outdated
[annotations addObject:annotationContext.annotation];
}
NSAssert(annotationContext.annotation, @"Missing annotation for tag %u.", annotationTag);
[annotations addObject:annotationContext.annotation];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#8163 (comment) mentions supplementing the fix with an assertion. This change fully removes the guard added in #8513. We can keep the assertion although I'm now confident we will hit it (or other similar assertions) from time to time when developing because of what I described in #8163 (comment)

Comment thread platform/ios/src/MGLMapView.mm Outdated
[annotations addObject:annotationContext.annotation];
}
NSAssert(annotationContext.annotation, @"Missing annotation for tag %u.", annotationTag);
[annotations addObject:annotationContext.annotation];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you’re at it, please add the same assertion and guard to the macOS implementation of -[MGLMapView visibleAnnotationsInRect:]. We should keep the two implementations consistent. Thanks!

@fabian-guerra
fabian-guerra force-pushed the fabian-visible-annotations-assert branch from 5c8651d to 6e27abe Compare April 5, 2017 15:57
@fabian-guerra
fabian-guerra merged commit ec34813 into release-ios-v3.5.0-android-v5.0.0 Apr 5, 2017
@fabian-guerra
fabian-guerra deleted the fabian-visible-annotations-assert branch April 5, 2017 18:17
mappy-mobile pushed a commit to Mappy/mapbox-gl-native that referenced this pull request Apr 12, 2017
…or_merge

* release-ios-v3.5.0-android-v5.0.0: (31 commits)
  [qt] Renamed qt5 formula to qt
  macos-v0.4.1
  [ios] Update podspecs and changelog for v3.5.2
  [ios, macos] Guard against looking up annotation contexts MGLAnnotationTagNotFound (mapbox#8686)
  [ios] Update podspecs and changelog for v3.5.1
  [ios, macos] Hardened std::map usage in MGLMapVIew
  [ios] replaced link to select a feature example (mapbox#8651)
  [ios, macos] Rename Data-driven styling guide (mapbox#8627)
  [ios] assertion to check if an annotationTag > 0 (mapbox#8588)
  [ios, macos] Preserve symlinks when zipping framework
  [ios] Silence incompatible type warning for callout view (mapbox#8608)
  Release android v5.0.2 (mapbox#8629)
  [macos] Removed MGLUserTrackingMode from jazzy ToC
  [macos] Fixed broken images in DDS guide
  [core] cache binary shaders on Android
  [core] Extract and de-templatize several Program static methods
  macos-v0.4.0
  [ios, macos] Updated changelogs
  [ios] Replaced UIActionSheet, UIAlertView with UIAlertController
  [ios, macos] Copyedited data-driven styling guides
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

iOS Mapbox Maps SDK for iOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants