[core] Emit MapChangeDidFailLoadingMap when the style cannot be loaded or parsed

Currently this signal is never emitted, which can cause the Still mode
to starve in case of an invalid style or failed request.
This commit is contained in:
Thiago Marcos P. Santos
2016-08-24 17:38:06 +03:00
parent 646528bc53
commit c98f4f476b
8 changed files with 41 additions and 12 deletions

View File

@@ -38,6 +38,7 @@ public:
Impl(View&, FileSource&, MapMode, GLContextMode, ConstrainMode, ViewportMode);
void onNeedsRepaint() override;
void onStyleError() override;
void onResourceError(std::exception_ptr) override;
void update();
@@ -316,6 +317,8 @@ void Map::setStyleURL(const std::string& url) {
} else {
Log::Error(Event::Setup, "loading style failed: %s", res.error->message.c_str());
}
impl->onStyleError();
impl->onResourceError(std::make_exception_ptr(std::runtime_error(res.error->message)));
} else if (res.notModified || res.noContent) {
return;
} else {
@@ -343,8 +346,8 @@ void Map::setStyleJSON(const std::string& json) {
}
void Map::Impl::loadStyleJSON(const std::string& json) {
style->setJSON(json);
style->setObserver(this);
style->setJSON(json);
styleJSON = json;
// force style cascade, causing all pending transitions to complete.
@@ -908,6 +911,10 @@ void Map::Impl::onNeedsRepaint() {
asyncUpdate.send();
}
void Map::Impl::onStyleError() {
view.notifyMapChange(MapChangeDidFailLoadingMap);
}
void Map::Impl::onResourceError(std::exception_ptr error) {
if (mode == MapMode::Still && callback) {
callback(error, {});