Make the FileSource available from the ThreadContext
For now we set the FileSource for the Worker context but in the future after fixing #1664 we can assert() that FileSource are set only for the Map thread context.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <mbgl/renderer/painter.hpp>
|
||||
|
||||
#include <mbgl/storage/file_source.hpp>
|
||||
#include <mbgl/storage/resource.hpp>
|
||||
#include <mbgl/storage/response.hpp>
|
||||
|
||||
@@ -35,6 +36,8 @@ MapContext::MapContext(uv_loop_t* loop, View& view_, FileSource& fileSource, Map
|
||||
texturePool(std::make_unique<TexturePool>()) {
|
||||
assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
|
||||
|
||||
util::ThreadContext::setFileSource(&fileSource);
|
||||
|
||||
asyncUpdate->unref();
|
||||
|
||||
view.activate();
|
||||
@@ -91,7 +94,8 @@ void MapContext::setStyleURL(const std::string& url) {
|
||||
base = styleURL.substr(0, pos + 1);
|
||||
}
|
||||
|
||||
env.request({ Resource::Kind::Style, styleURL }, [this, base](const Response &res) {
|
||||
FileSource* fs = util::ThreadContext::getFileSource();
|
||||
fs->request({ Resource::Kind::Style, styleURL }, util::RunLoop::current.get()->get(), [this, base](const Response &res) {
|
||||
if (res.status == Response::Successful) {
|
||||
loadStyleJSON(res.data, base);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user