parse line width function and call tile destructor from main thread

This commit is contained in:
Konstantin Käfer
2014-01-29 12:25:50 +01:00
parent 04e16cf2ca
commit d5cae14770
9 changed files with 70 additions and 24 deletions

View File

@@ -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() {