diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2015-06-16 13:08:38 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2015-06-16 14:06:29 +0300 |
commit | 57c34747a24bc2c3e5b27e17c1991d6b9a4aa68c (patch) | |
tree | 5ecaf31c9409717d19251d870264dceac3afb452 /src | |
parent | 556938e8bb3b4d302ca20c034c648c67afb83a63 (diff) | |
download | qtlocation-mapboxgl-57c34747a24bc2c3e5b27e17c1991d6b9a4aa68c.tar.gz |
Report errors for renderStill() misuse using the callback
Use the callback provided for reporting the errors instead of throwing
an exception. The problem with the exception is it will happen on the
Map thread which makes it impossible to the user of our API to catch,
ultimately resulting in a crash.
In the scenario of not providing a callback, we just print an error.
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/map_context.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index bd288a5cda..7f8323137b 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -279,12 +279,24 @@ void MapContext::update() { } void MapContext::renderStill(StillImageCallback fn) { + if (!fn) { + Log::Error(Event::General, "StillImageCallback not set"); + return; + } + if (data.mode != MapMode::Still) { - throw util::Exception("Map is not in still image render mode"); + fn(std::make_exception_ptr(util::MisuseException("Map is not in still image render mode")), nullptr); + return; } if (callback) { - throw util::Exception("Map is currently rendering an image"); + fn(std::make_exception_ptr(util::MisuseException("Map is currently rendering an image")), nullptr); + return; + } + + if (!style) { + fn(std::make_exception_ptr(util::MisuseException("Map doesn't have a style")), nullptr); + return; } if (style->getLastError()) { |