[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:
@@ -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, {});
|
||||
|
||||
Reference in New Issue
Block a user