diff --git a/src/mbgl/map/tile_data.cpp b/src/mbgl/map/tile_data.cpp index bb8d18d12f7..80fd6346d3d 100644 --- a/src/mbgl/map/tile_data.cpp +++ b/src/mbgl/map/tile_data.cpp @@ -60,13 +60,16 @@ void TileData::cancel() { void TileData::reparse(Worker& worker, std::function callback) { util::ptr tile = shared_from_this(); worker.send( - [tile]() { - EnvironmentScope scope(tile->env, ThreadType::TileWorker, "TileWorker_" + tile->name); - tile->parse(); + [this]() { + EnvironmentScope scope(env, ThreadType::TileWorker, "TileWorker_" + name); + parse(); }, [tile, callback]() { // `tile` is bound in this lambda to ensure that if it's the last owning pointer, - // destruction happens on the map thread, not the worker thread. + // destruction happens on the map thread, not the worker thread. It is _not_ bound + // in the above lambda, because we do not want the possibility to arise that the + // after callback could execute and release the penultimate reference before the + // work callback has been destructed. callback(); }); }