summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2014-12-04 12:09:27 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2014-12-04 15:26:54 -0800
commit36500b9f957dec5336cb080784e6099408cf6af8 (patch)
tree29e5d5363932f683674affe8e967227fa6c2f08d /src
parent16fe8e64c4d47ac35fa6dd594342d3a265af358b (diff)
downloadqtlocation-mapboxgl-36500b9f957dec5336cb080784e6099408cf6af8.tar.gz
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
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/map/map.cpp7
-rw-r--r--src/mbgl/storage/caching_http_file_source.cpp35
2 files changed, 23 insertions, 19 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index 1a45284757..2113ba6583 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<Style>();
}
style->loadJSON((const uint8_t *)styleJSON.c_str());
- if (!fileSource.hasLoop()) {
- fileSource.setLoop(**loop);
- glyphStore = std::make_shared<GlyphStore>(fileSource);
- }
+ glyphStore = std::make_shared<GlyphStore>(fileSource);
fileSource.setBase(base);
glyphStore->setURL(util::mapbox::normalizeGlyphsURL(style->glyph_url, getAccessToken()));
update();
diff --git a/src/mbgl/storage/caching_http_file_source.cpp b/src/mbgl/storage/caching_http_file_source.cpp
index 64582ba5d4..cf23ca1763 100644
--- a/src/mbgl/storage/caching_http_file_source.cpp
+++ b/src/mbgl/storage/caching_http_file_source.cpp
@@ -13,21 +13,6 @@ CachingHTTPFileSource::CachingHTTPFileSource(const std::string &path_)
: path(path_) {}
CachingHTTPFileSource::~CachingHTTPFileSource() {
- if (hasLoop()) {
- assert(thread_id == std::this_thread::get_id());
- uv_messenger_stop(queue, [](uv_messenger_t *msgr) {
- delete msgr;
- });
-
- util::ptr<BaseRequest> req;
-
- // Send a cancel() message to all requests that we are still holding.
- for (const std::pair<std::string, std::weak_ptr<BaseRequest>> &pair : pending) {
- if ((req = pair.second.lock())) {
- req->cancel();
- }
- }
- }
}
void CachingHTTPFileSource::setLoop(uv_loop_t* loop_) {
@@ -47,6 +32,26 @@ bool CachingHTTPFileSource::hasLoop() {
return loop;
}
+void CachingHTTPFileSource::clearLoop() {
+ assert(thread_id == std::this_thread::get_id());
+ assert(loop);
+
+ uv_messenger_stop(queue, [](uv_messenger_t *msgr) {
+ delete msgr;
+ });
+
+ util::ptr<BaseRequest> req;
+
+ // Send a cancel() message to all requests that we are still holding.
+ for (const std::pair<std::string, std::weak_ptr<BaseRequest>> &pair : pending) {
+ if ((req = pair.second.lock())) {
+ req->cancel();
+ }
+ }
+
+ store.reset();
+}
+
void CachingHTTPFileSource::setBase(const std::string &value) {
assert(thread_id == std::this_thread::get_id());
base = value;