From 0406a8229903c880dc37fe5a6654fd49f9e3d4f5 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Tue, 25 Feb 2014 15:34:32 -0800 Subject: [PATCH] add tile state 'loaded' --- include/llmr/map/tile.hpp | 1 + src/map/tile.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/llmr/map/tile.hpp b/include/llmr/map/tile.hpp index 297da8b71..74bc1d472 100644 --- a/include/llmr/map/tile.hpp +++ b/include/llmr/map/tile.hpp @@ -43,6 +43,7 @@ public: enum state { initial, loading, + loaded, parsed, obsolete }; diff --git a/src/map/tile.cpp b/src/map/tile.cpp index cd8f686b1..d0fd329d2 100644 --- a/src/map/tile.cpp +++ b/src/map/tile.cpp @@ -76,7 +76,8 @@ void Tile::request() { // Note: Somehow this feels slower than the change to request_http() std::shared_ptr tile = shared_from_this(); platform::request_http_tile(url, tile, [=](platform::Response& res) { - if (res.code == 200) { + if (res.code == 200 && tile->state != obsolete) { + tile->state = Tile::loaded; tile->data.swap(res.body); tile->parse(); } else { @@ -99,7 +100,7 @@ void Tile::cancel() { bool Tile::parse() { // std::lock_guard lock(mtx); - if (state == obsolete) { + if (state != loaded) { return false; }