diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2015-05-29 12:13:24 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2015-06-04 14:44:34 +0300 |
commit | 29b8b44b7767312095e9489a97ba9eea3f1797af (patch) | |
tree | 3595649606d6402b80f602505daee5688eae121e /src | |
parent | 9b36b48268cacd6e488631235aba5f593900f7b9 (diff) | |
download | qtlocation-mapboxgl-29b8b44b7767312095e9489a97ba9eea3f1797af.tar.gz |
Fix race condition on error notification
We start loading the resources at the moment we set the style, but we
set the callback for error notification at renderStill(), which happen
afterwards.
If some error occurs in this short window, it was never being notified.
Now we save the last error and we check after we set the callback.
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/map_context.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/style/style.cpp | 1 | ||||
-rw-r--r-- | src/mbgl/style/style.hpp | 6 |
3 files changed, 12 insertions, 0 deletions
diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index a834f50655..47a6b3e4bb 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -176,6 +176,11 @@ void MapContext::renderStill(StillImageCallback fn) { throw util::Exception("Map is currently rendering an image"); } + if (style->getLastError()) { + fn(style->getLastError(), nullptr); + return; + } + callback = fn; triggerUpdate(Update::RenderStill); } diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index 8999af3c7f..30798e08eb 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -203,6 +203,7 @@ void Style::emitResourceLoadingFailed(std::exception_ptr error) { try { if (error) { + lastError = error; std::rethrow_exception(error); } } catch(const std::exception& e) { diff --git a/src/mbgl/style/style.hpp b/src/mbgl/style/style.hpp index c70f019c43..a22067cb16 100644 --- a/src/mbgl/style/style.hpp +++ b/src/mbgl/style/style.hpp @@ -59,6 +59,10 @@ public: void setDefaultTransitionDuration(Duration); bool hasTransitions() const; + std::exception_ptr getLastError() const { + return lastError; + } + std::unique_ptr<GlyphStore> glyphStore; std::unique_ptr<GlyphAtlas> glyphAtlas; util::ptr<Sprite> sprite; @@ -90,6 +94,8 @@ private: Observer* observer = nullptr; + std::exception_ptr lastError; + std::string spriteURL; PropertyTransition defaultTransition; std::unique_ptr<uv::rwlock> mtx; |