diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-03-19 16:57:36 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-03-20 21:30:08 +0200 |
commit | d5868d3da822f2bf3297229bd879e76853108a63 (patch) | |
tree | b3d28aab92b938cf541f917f1027d2bbd06d9780 /platform/glfw | |
parent | d1762d7111b39d45430bd7bb75ea60b7a5d85bd2 (diff) | |
download | qtlocation-mapboxgl-d5868d3da822f2bf3297229bd879e76853108a63.tar.gz |
[core] Remove file source from public Map ctor
Diffstat (limited to 'platform/glfw')
-rw-r--r-- | platform/glfw/main.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/platform/glfw/main.cpp b/platform/glfw/main.cpp index 38a41cbf18..8288a009f2 100644 --- a/platform/glfw/main.cpp +++ b/platform/glfw/main.cpp @@ -93,23 +93,22 @@ int main(int argc, char *argv[]) { GLFWView backend(fullscreen, benchmark); view = &backend; - mbgl::DefaultFileSource fileSource(cacheDB, "."); - if (!settings.online) { - fileSource.setOnlineStatus(false); - mbgl::Log::Warning(mbgl::Event::Setup, "Application is offline. Press `O` to toggle online status."); - } - // Set access token if present const char *token = getenv("MAPBOX_ACCESS_TOKEN"); if (token == nullptr) { mbgl::Log::Warning(mbgl::Event::Setup, "no access token set. mapbox.com tiles won't work."); - } else { - fileSource.setAccessToken(std::string(token)); + } + + auto resourceOptions = mbgl::ResourceOptions().withCachePath(cacheDB).withAssetPath(".").withAccessToken(std::string(token)); + auto fileSource = std::static_pointer_cast<mbgl::DefaultFileSource>(mbgl::FileSource::getSharedFileSource(resourceOptions)); + if (!settings.online) { + fileSource->setOnlineStatus(false); + mbgl::Log::Warning(mbgl::Event::Setup, "Application is offline. Press `O` to toggle online status."); } mbgl::ThreadPool threadPool(4); GLFWRendererFrontend rendererFrontend { std::make_unique<mbgl::Renderer>(backend, view->getPixelRatio(), threadPool), backend }; - mbgl::Map map(rendererFrontend, backend, view->getSize(), view->getPixelRatio(), fileSource, threadPool, mbgl::MapOptions()); + mbgl::Map map(rendererFrontend, backend, view->getSize(), view->getPixelRatio(), threadPool, mbgl::MapOptions(), resourceOptions); backend.setMap(&map); @@ -124,9 +123,9 @@ int main(int argc, char *argv[]) { .withPitch(settings.pitch)); map.setDebug(mbgl::MapDebugOptions(settings.debug)); - view->setOnlineStatusCallback([&settings, &fileSource]() { + view->setOnlineStatusCallback([&settings, fileSource]() { settings.online = !settings.online; - fileSource.setOnlineStatus(settings.online); + fileSource->setOnlineStatus(settings.online); mbgl::Log::Info(mbgl::Event::Setup, "Application is %s. Press `O` to toggle online status.", settings.online ? "online" : "offline"); }); @@ -144,13 +143,13 @@ int main(int argc, char *argv[]) { mbgl::Log::Info(mbgl::Event::Setup, "Changed style to: %s", newStyle.name); }); - view->setPauseResumeCallback([&fileSource] () { + view->setPauseResumeCallback([fileSource] () { static bool isPaused = false; if (isPaused) { - fileSource.resume(); + fileSource->resume(); } else { - fileSource.pause(); + fileSource->pause(); } isPaused = !isPaused; |