From 86cccc4d24804d40ea9d15d47ee1edb975bbf2e3 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 21 Jul 2016 16:37:18 -0700 Subject: [PATCH] [core] Don't allow style mutations to be overwritten by revalidation * Once we get a fresh style, stop revalidating. * If the style is mutated, stop revalidating and preserve the existing mutations. --- include/mbgl/storage/response.hpp | 4 ++ src/mbgl/map/map.cpp | 20 ++++++++ test/map/map.cpp | 64 +++++++++++++++++++++++++ test/src/mbgl/test/fake_file_source.hpp | 60 +++++++++++++++++++++++ 4 files changed, 148 insertions(+) create mode 100644 test/src/mbgl/test/fake_file_source.hpp diff --git a/include/mbgl/storage/response.hpp b/include/mbgl/storage/response.hpp index 6c79f5e18..4dc3f3668 100644 --- a/include/mbgl/storage/response.hpp +++ b/include/mbgl/storage/response.hpp @@ -32,6 +32,10 @@ public: optional modified; optional expires; optional etag; + + bool isFresh() const { + return !expires || *expires > util::now(); + } }; class Response::Error { diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 15f7779f8..2e7dc06e8 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -67,6 +67,7 @@ public: std::string styleURL; std::string styleJSON; + bool styleMutated = false; std::unique_ptr styleRequest; @@ -293,10 +294,21 @@ void Map::setStyleURL(const std::string& url) { impl->styleRequest = nullptr; impl->styleURL = url; impl->styleJSON.clear(); + impl->styleMutated = false; impl->style = std::make_unique