[core] Localize and simplify state for MapChangeDidFinishLoadingMap event
Only Map needs to track this state, and it can simply be set when beginning to load a style and reset when finished.
This commit is contained in:
@@ -205,6 +205,7 @@ private:
|
||||
};
|
||||
|
||||
RenderState renderState = RenderState::never;
|
||||
bool loading = false;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -78,8 +78,8 @@ void Map::renderSync() {
|
||||
} else if (renderState != RenderState::fully) {
|
||||
renderState = RenderState::fully;
|
||||
view.notifyMapChange(MapChangeDidFinishRenderingMapFullyRendered);
|
||||
if (data->loading) {
|
||||
data->loading = false;
|
||||
if (loading) {
|
||||
loading = false;
|
||||
view.notifyMapChange(MapChangeDidFinishLoadingMap);
|
||||
}
|
||||
}
|
||||
@@ -101,11 +101,13 @@ void Map::update(Update flags) {
|
||||
#pragma mark - Style
|
||||
|
||||
void Map::setStyleURL(const std::string &url) {
|
||||
loading = true;
|
||||
view.notifyMapChange(MapChangeWillStartLoadingMap);
|
||||
context->invoke(&MapContext::setStyleURL, url);
|
||||
}
|
||||
|
||||
void Map::setStyleJSON(const std::string& json, const std::string& base) {
|
||||
loading = true;
|
||||
view.notifyMapChange(MapChangeWillStartLoadingMap);
|
||||
context->invoke(&MapContext::setStyleJSON, json, base);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,6 @@ void MapContext::setStyleURL(const std::string& url) {
|
||||
Log::Error(Event::Setup, "style %s could not be found or is an incompatible legacy map or style", styleURL.c_str());
|
||||
} else {
|
||||
Log::Error(Event::Setup, "loading style failed: %s", res.error->message.c_str());
|
||||
data.loading = false;
|
||||
}
|
||||
} else if (res.notModified || res.noContent) {
|
||||
return;
|
||||
@@ -142,10 +141,6 @@ void MapContext::loadStyleJSON(const std::string& json, const std::string& base)
|
||||
// force style cascade, causing all pending transitions to complete.
|
||||
style->cascade();
|
||||
|
||||
// set loading here so we don't get a false loaded event as soon as map is
|
||||
// created but before a style is loaded
|
||||
data.loading = true;
|
||||
|
||||
updateFlags |= Update::DefaultTransition | Update::Classes | Update::Zoom | Update::Annotations;
|
||||
asyncUpdate.send();
|
||||
}
|
||||
|
||||
@@ -149,7 +149,6 @@ public:
|
||||
bool paused = false;
|
||||
std::mutex mutexPause;
|
||||
std::condition_variable condPause;
|
||||
bool loading = false;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
Reference in New Issue
Block a user