parse line width function and call tile destructor from main thread
This commit is contained in:
@@ -132,6 +132,7 @@ Tile::Ptr Map::addTile(const Tile::ID& id) {
|
||||
// std::cerr << "init " << id.z << "/" << id.x << "/" << id.y << std::endl;
|
||||
// std::cerr << "add " << tile->toString() << std::endl;
|
||||
tiles.push_front(tile);
|
||||
historic_tiles.push_front(tile);
|
||||
}
|
||||
|
||||
return tile;
|
||||
@@ -273,6 +274,16 @@ void Map::updateTiles() {
|
||||
tiles.sort([](const Tile::Ptr& a, const Tile::Ptr& b) {
|
||||
return a->id.z > b->id.z;
|
||||
});
|
||||
|
||||
|
||||
// Remove all tiles that are only in the list of historic tiles. We do this
|
||||
// to make sure that the destructor (triggered by shared_ptr count falling
|
||||
// to 0) is triggered from the main thread.
|
||||
// TODO: Find a better solution by forcing the destructor to run in the
|
||||
// main thread, e.g. with a custom deleter on shared_ptr construction?
|
||||
historic_tiles.remove_if([](const Tile::Ptr& tile) {
|
||||
return tile.unique();
|
||||
});
|
||||
}
|
||||
|
||||
bool Map::render() {
|
||||
|
||||
Reference in New Issue
Block a user