diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-07-06 13:53:30 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-07-08 19:46:02 +0200 |
commit | d37bd549bc4bcaa80df667e6e218251607d94586 (patch) | |
tree | 1394c3d2aab6fd1db916d3a86212e9ad2a46bba6 /src | |
parent | 32699333e64c8b26011ce311aa8a759f1b8dcfaa (diff) | |
download | qtlocation-mapboxgl-d37bd549bc4bcaa80df667e6e218251607d94586.tar.gz |
make sure that the SpriteStore object correctly replaces the SpriteImages
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/annotation/sprite_store.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/mbgl/annotation/sprite_store.cpp b/src/mbgl/annotation/sprite_store.cpp index ac7730fb4e..1cc5d76412 100644 --- a/src/mbgl/annotation/sprite_store.cpp +++ b/src/mbgl/annotation/sprite_store.cpp @@ -13,14 +13,24 @@ void SpriteStore::_setSprite(const std::string& name, const std::shared_ptr<const SpriteImage>& sprite) { if (sprite) { auto it = sprites.find(name); - if (it != sprites.end() && - (it->second->width != sprite->width || it->second->height != sprite->height)) { - Log::Warning(Event::Sprite, "Can't change sprite dimensions for '%s'", name.c_str()); - return; + if (it != sprites.end()) { + // There is already a sprite with that name in our store. + if ((it->second->width != sprite->width || it->second->height != sprite->height)) { + Log::Warning(Event::Sprite, "Can't change sprite dimensions for '%s'", name.c_str()); + return; + } + it->second = sprite; + } else { + sprites.emplace(name, sprite); } - sprites.emplace_hint(it, name, sprite); - dirty.emplace(name, sprite); + // Always add/replace the value in the dirty list. + auto dirty_it = dirty.find(name); + if (dirty_it != dirty.end()) { + dirty_it->second = sprite; + } else { + dirty.emplace(name, sprite); + } } else if (sprites.erase(name) > 0) { dirty.emplace(name, nullptr); } |