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

Fix annotation icon replacement #3320

Merged
merged 1 commit into from
Dec 16, 2015

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented Dec 16, 2015

Another pass at #3146, including a unit test. Map::removeAnnotationIcon() was calling itself recursively instead of MapContext::removeAnnotationIcon(), and an iterator in SpriteAtlas::updateDirty() needs to be incremented before the current element is removed from the map. Thanks to @jfirebaugh for spotting these issues.

/cc @RomainQuidet

Another pass at #3146, including a unit test.
@1ec5 1ec5 added iOS Mapbox Maps SDK for iOS crash labels Dec 16, 2015
@1ec5 1ec5 self-assigned this Dec 16, 2015
@1ec5 1ec5 added this to the ios-v3.1.0 milestone Dec 16, 2015
} else {
images.erase(imageIterator);
images.erase(imageIterator++);
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be prefix increment -- images.erase(++imageIterator). (For anyone who doesn't know: the reason is that std::map::erase invalidates any iterators pointing to the erased element. Prefix ++ both returns the original value for passing to erase, and increments just before the call. This is both very subtle and a standard C++ idiom in this situation.)

Copy link
Contributor

Choose a reason for hiding this comment

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

And of course, after writing that I realized I had it backwards. The current code is correct!

@RomainQuidet
Copy link
Contributor

Thanks for that, I'll try to add unit tests next time and better double check after pull request update

@1ec5 1ec5 merged commit e304033 into master Dec 16, 2015
@1ec5 1ec5 removed the in progress label Dec 16, 2015
@1ec5 1ec5 deleted the 1ec5-annotation-image-update-3146-review branch December 16, 2015 17:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crash iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants