fix crash bug for styles that have no glyph url specified

This commit is contained in:
Konstantin Käfer
2014-08-06 18:33:21 +02:00
parent 915e89bee8
commit 9dc48b773f
3 changed files with 15 additions and 14 deletions

View File

@@ -33,6 +33,7 @@ Map::Map(View& view)
transform(view),
style(std::make_shared<Style>()),
glyphAtlas(std::make_shared<GlyphAtlas>(1024, 1024)),
glyphStore(std::make_shared<GlyphStore>()),
spriteAtlas(std::make_shared<SpriteAtlas>(512, 512)),
texturepool(std::make_shared<Texturepool>()),
painter(*this),
@@ -187,6 +188,7 @@ void Map::setStyleJSON(std::string newStyleJSON) {
styleJSON.swap(newStyleJSON);
sprite.reset();
style->loadJSON((const uint8_t *)styleJSON.c_str());
glyphStore->setURL(style->glyph_url);
update();
}
@@ -514,16 +516,6 @@ void Map::prepare() {
bool dimensionsChanged = oldState.getFramebufferWidth() != state.getFramebufferWidth() ||
oldState.getFramebufferHeight() != state.getFramebufferHeight();
// Create a new glyph store object in case the glyph URL changed.
// TODO: Move this to a less frequently called place; we only need to do this when the
// stylesheet changes.
if (glyphStore && glyphStore->glyphURL != style->glyph_url) {
glyphStore.reset();
}
if (!glyphStore && style->glyph_url.size()) {
glyphStore = std::make_shared<GlyphStore>(style->glyph_url);
}
if (pixelRatioChanged || dimensionsChanged) {
painter.clearFramebuffers();
}