From 36500b9f957dec5336cb080784e6099408cf6af8 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 4 Dec 2014 12:09:27 -0800 Subject: [PATCH] Add CachingHTTPFileSource::clearLoop() So loop state can be cleaned up in the appropriate thread. This is a hack; loop needs to be externalized from Map. Fixes #686 --- .../mbgl/storage/caching_http_file_source.hpp | 1 + include/mbgl/storage/file_source.hpp | 3 ++ src/mbgl/map/map.cpp | 7 ++-- src/mbgl/storage/caching_http_file_source.cpp | 35 +++++++++++-------- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/include/mbgl/storage/caching_http_file_source.hpp b/include/mbgl/storage/caching_http_file_source.hpp index 403db3183..f566acf49 100644 --- a/include/mbgl/storage/caching_http_file_source.hpp +++ b/include/mbgl/storage/caching_http_file_source.hpp @@ -21,6 +21,7 @@ public: // Stores and checks the libuv loop for requests void setLoop(uv_loop_t*); bool hasLoop(); + void clearLoop(); // Stores and retrieves the base path/URL for relative requests void setBase(const std::string &value); diff --git a/include/mbgl/storage/file_source.hpp b/include/mbgl/storage/file_source.hpp index c8f621787..69a0060f6 100644 --- a/include/mbgl/storage/file_source.hpp +++ b/include/mbgl/storage/file_source.hpp @@ -16,8 +16,11 @@ namespace mbgl { class FileSource : public util::noncopyable { public: virtual ~FileSource() = default; + virtual void setLoop(uv_loop_t*) = 0; virtual bool hasLoop() = 0; + virtual void clearLoop() = 0; + virtual void setBase(const std::string &value) = 0; virtual std::unique_ptr request(ResourceType type, const std::string &url) = 0; virtual void prepare(std::function fn) = 0; diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 1a4528475..2113ba658 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -151,6 +151,8 @@ void Map::start() { workers.reset(); activeSources.clear(); + fileSource.clearLoop(); + // Closes all open handles on the loop. This means that the loop will automatically terminate. asyncCleanup.reset(); asyncRender.reset(); @@ -310,10 +312,7 @@ void Map::setStyleJSON(std::string newStyleJSON, const std::string &base) { style = std::make_shared