diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/map.cpp | 17 | ||||
-rw-r--r-- | src/map/vector_tile_data.cpp | 16 |
2 files changed, 24 insertions, 9 deletions
diff --git a/src/map/map.cpp b/src/map/map.cpp index f71ecdb270..4b797ceae3 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -58,6 +58,15 @@ Map::~Map() { if (async) { stop(); } + + // Explicitly reset all pointers. + texturepool.reset(); + sprite.reset(); + spriteAtlas.reset(); + glyphStore.reset(); + glyphAtlas.reset(); + style.reset(); + fileSource.reset(); } uv::worker &Map::getWorker() { @@ -265,8 +274,14 @@ void Map::setStyleJSON(std::string newStyleJSON, const std::string &base) { // TODO: Make threadsafe. styleJSON.swap(newStyleJSON); sprite.reset(); - assert(style); + if (!style) { + style = std::make_shared<Style>(); + } style->loadJSON((const uint8_t *)styleJSON.c_str()); + if (!fileSource) { + fileSource = std::make_shared<FileSource>(**loop, platform::defaultCacheDatabase()); + glyphStore = std::make_shared<GlyphStore>(fileSource); + } fileSource->setBase(base); glyphStore->setURL(util::mapbox::normalizeGlyphsURL(style->glyph_url, getAccessToken())); update(); diff --git a/src/map/vector_tile_data.cpp b/src/map/vector_tile_data.cpp index e34ed94188..48b46059a5 100644 --- a/src/map/vector_tile_data.cpp +++ b/src/map/vector_tile_data.cpp @@ -30,18 +30,18 @@ void VectorTileData::parse() { return; } -// try { + try { // Parsing creates state that is encapsulated in TileParser. While parsing, // the TileParser object writes results into this objects. All other state // is going to be discarded afterwards. parser->parse(); -// } catch (const std::exception& ex) { -//#if defined(DEBUG) -// fprintf(stderr, "[%p] exception [%d/%d/%d]... failed: %s\n", this, id.z, id.x, id.y, ex.what()); -//#endif -// cancel(); -// return; -// } + } catch (const std::exception& ex) { +#if defined(DEBUG) + fprintf(stderr, "[%p] exception [%d/%d/%d]... failed: %s\n", this, id.z, id.x, id.y, ex.what()); +#endif + cancel(); + return; + } if (state != State::obsolete) { state = State::parsed; |