diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2017-07-13 15:35:02 +0300 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2017-07-19 17:34:07 +0200 |
commit | 733661948c004dad70e634aa9f2b41402e460a6e (patch) | |
tree | 0f4cc6e0ad280eafff1fc757b419ce49b28ce6b2 /include | |
parent | 2d147470a5f982afb0c1a63ff632497f85ea85bf (diff) | |
download | qtlocation-mapboxgl-733661948c004dad70e634aa9f2b41402e460a6e.tar.gz |
[core] BackendScope prevent double (de-)activation
- Guards against duplicate activations by checking wether the backend of the prior scope is the same as the current ones
- Makes sure that only the most outer backend scope deactivates by tracking activation state
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/map/backend.hpp | 5 | ||||
-rw-r--r-- | include/mbgl/map/backend_scope.hpp | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/include/mbgl/map/backend.hpp b/include/mbgl/map/backend.hpp index 884c4b5256..69a998709b 100644 --- a/include/mbgl/map/backend.hpp +++ b/include/mbgl/map/backend.hpp @@ -3,6 +3,7 @@ #include <mbgl/map/map_observer.hpp> #include <mbgl/util/image.hpp> #include <mbgl/util/size.hpp> +#include <mbgl/util/util.hpp> #include <memory> #include <mutex> @@ -80,4 +81,8 @@ private: friend class BackendScope; }; +constexpr bool operator==(const Backend& a, const Backend& b) { + return &a == &b; +} + } // namespace mbgl diff --git a/include/mbgl/map/backend_scope.hpp b/include/mbgl/map/backend_scope.hpp index 4985cd197f..322c17b3fc 100644 --- a/include/mbgl/map/backend_scope.hpp +++ b/include/mbgl/map/backend_scope.hpp @@ -22,10 +22,14 @@ public: static bool exists(); private: + void activate(); + void deactivate(); + BackendScope* priorScope; BackendScope* nextScope; Backend& backend; const ScopeType scopeType; + bool activated = false; }; } // namespace mbgl |