diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2016-12-06 17:24:32 +0100 |
---|---|---|
committer | Jesse Bounds <jesse@rebounds.net> | 2016-12-13 10:03:05 -0800 |
commit | 18730d598d29cf876064ce6964ef88ef0351f78f (patch) | |
tree | 5ca7d6f7b7e42c3845e251f063885f88bf3ae982 /src | |
parent | 1ab791c3dc15ee5d7bb8045e15a6ea4782b2e337 (diff) | |
download | qtlocation-mapboxgl-18730d598d29cf876064ce6964ef88ef0351f78f.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 f6ee6a5650..868b748af4 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -140,7 +140,7 @@ Map::Impl::Impl(Backend& backend_, } Map::~Map() { - impl->backend.activate(); + BackendScope guard(impl->backend); impl->styleRequest = nullptr; @@ -149,8 +149,6 @@ Map::~Map() { impl->style.reset(); impl->annotationManager.reset(); impl->painter.reset(); - - impl->backend.deactivate(); } void Map::renderStill(View& view, StillImageCallback callback) { @@ -275,9 +273,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; @@ -848,12 +845,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) { @@ -862,13 +857,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; } @@ -1033,9 +1026,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(); |