diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2016-12-06 17:24:32 +0100 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2016-12-12 09:05:23 -0500 |
commit | c76a933514e4e1514a58ac0e668b13eebab37794 (patch) | |
tree | c369563359007d730f427e04d9fd4945f3f97fbc /src | |
parent | ffd74c309e0b44bdf3ff09c6c1dc715ad97f64cd (diff) | |
download | qtlocation-mapboxgl-c76a933514e4e1514a58ac0e668b13eebab37794.tar.gz |
[core] use raii to guard backend deactivation
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/map.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 40f4e91c9d..7e7d0417b9 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -147,7 +147,7 @@ Map::Impl::Impl(Map& map_, } Map::~Map() { - impl->backend.activate(); + BackendScope guard(impl->backend); impl->styleRequest = nullptr; @@ -156,8 +156,6 @@ Map::~Map() { impl->style.reset(); impl->annotationManager.reset(); impl->painter.reset(); - - impl->backend.deactivate(); } void Map::renderStill(View& view, StillImageCallback callback) { @@ -282,9 +280,8 @@ void Map::Impl::update() { backend.invalidate(); } else if (stillImageRequest && style->isLoaded()) { // TODO: determine whether we need activate/deactivate - backend.activate(); + BackendScope guard(backend); render(stillImageRequest->view); - backend.deactivate(); } updateFlags = Update::Nothing; @@ -882,12 +879,10 @@ void Map::addLayer(std::unique_ptr<Layer> layer, const optional<std::string>& be } impl->styleMutated = true; - impl->backend.activate(); + BackendScope guard(impl->backend); impl->style->addLayer(std::move(layer), before); impl->onUpdate(Update::Classes); - - impl->backend.deactivate(); } std::unique_ptr<Layer> Map::removeLayer(const std::string& id) { @@ -896,13 +891,11 @@ std::unique_ptr<Layer> Map::removeLayer(const std::string& id) { } impl->styleMutated = true; - impl->backend.activate(); + BackendScope guard(impl->backend); auto removedLayer = impl->style->removeLayer(id); impl->onUpdate(Update::Classes); - impl->backend.deactivate(); - return removedLayer; } @@ -1060,9 +1053,8 @@ void Map::setSourceTileCacheSize(size_t size) { void Map::onLowMemory() { if (impl->painter) { - impl->backend.activate(); + BackendScope guard(impl->backend); impl->painter->cleanup(); - impl->backend.deactivate(); } if (impl->style) { impl->style->onLowMemory(); |