diff options
author | Sudarsana Babu Nagineni <sudarsana.babu@mapbox.com> | 2019-04-03 15:08:02 +0300 |
---|---|---|
committer | Sudarsana Babu Nagineni <sudarsana.babu@mapbox.com> | 2019-04-29 17:09:58 +0300 |
commit | 2604991b2b0090ed69893f6b156a6e640a789c9f (patch) | |
tree | d6b29f0a512b3de53fb4cc23d96cc2f52b1fdffe /platform/glfw | |
parent | 4c8295e67200e15979ddc0c6b16d9b09e4f0a192 (diff) | |
download | qtlocation-mapboxgl-2604991b2b0090ed69893f6b156a6e640a789c9f.tar.gz |
[core] Introduce resetCache API
Add an API to delete existing database and re-initialize.
Diffstat (limited to 'platform/glfw')
-rw-r--r-- | platform/glfw/glfw_view.cpp | 4 | ||||
-rw-r--r-- | platform/glfw/glfw_view.hpp | 5 | ||||
-rw-r--r-- | platform/glfw/main.cpp | 9 |
3 files changed, 18 insertions, 0 deletions
diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index 2772ed0773..fe956d8a68 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -124,6 +124,7 @@ GLFWView::GLFWView(bool fullscreen_, bool benchmark_) printf("- Press `O` to toggle online connectivity\n"); printf("- Press `Z` to cycle through north orientations\n"); printf("- Prezz `X` to cycle through the viewport modes\n"); + printf("- Press `I` to Delete existing database and re-initialize\n"); printf("- Press `A` to cycle through Mapbox offices in the world + dateline monument\n"); printf("- Press `B` to cycle through the color, stencil, and depth buffer\n"); printf("- Press `D` to cycle through camera bounds: inside, crossing IDL at left, crossing IDL at right, and disabled\n"); @@ -221,6 +222,9 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, case GLFW_KEY_C: view->clearAnnotations(); break; + case GLFW_KEY_I: + view->resetCacheCallback(); + break; case GLFW_KEY_K: view->addRandomCustomPointAnnotations(1); break; diff --git a/platform/glfw/glfw_view.hpp b/platform/glfw/glfw_view.hpp index 9b580f80cc..1957970b85 100644 --- a/platform/glfw/glfw_view.hpp +++ b/platform/glfw/glfw_view.hpp @@ -40,6 +40,10 @@ public: onlineStatusCallback = callback; } + void setResetCacheCallback(std::function<void()> callback) { + resetCacheCallback = callback; + }; + void setShouldClose(); void setWindowTitle(const std::string&); @@ -120,6 +124,7 @@ private: std::function<void()> changeStyleCallback; std::function<void()> pauseResumeCallback; std::function<void()> onlineStatusCallback; + std::function<void()> resetCacheCallback; std::function<void(mbgl::Map*)> animateRouteCallback; mbgl::util::RunLoop runLoop; diff --git a/platform/glfw/main.cpp b/platform/glfw/main.cpp index 0a4ace6a19..4e631ec895 100644 --- a/platform/glfw/main.cpp +++ b/platform/glfw/main.cpp @@ -6,6 +6,7 @@ #include <mbgl/util/logging.hpp> #include <mbgl/util/platform.hpp> #include <mbgl/util/default_thread_pool.hpp> +#include <mbgl/util/string.hpp> #include <mbgl/storage/default_file_source.hpp> #include <mbgl/style/style.hpp> #include <mbgl/renderer/renderer.hpp> @@ -159,6 +160,14 @@ int main(int argc, char *argv[]) { isPaused = !isPaused; }); + view->setResetCacheCallback([fileSource] () { + fileSource->resetCache([](std::exception_ptr ex) { + if (ex) { + mbgl::Log::Error(mbgl::Event::Database, "Failed to reset cache:: %s", mbgl::util::toString(ex).c_str()); + } + }); + }); + // Load style if (style.empty()) { const char *url = getenv("MAPBOX_STYLE_URL"); |