From 9ebf727f56819f259a7a0771b1ed58b14c3adea3 Mon Sep 17 00:00:00 2001 From: Ivo van Dongen Date: Thu, 13 Jul 2017 15:35:02 +0300 Subject: [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 --- include/mbgl/renderer/backend_scope.hpp | 4 ++++ include/mbgl/renderer/renderer_backend.hpp | 5 +++++ 2 files changed, 9 insertions(+) (limited to 'include') diff --git a/include/mbgl/renderer/backend_scope.hpp b/include/mbgl/renderer/backend_scope.hpp index f8a258f3df..73bafc84c7 100644 --- a/include/mbgl/renderer/backend_scope.hpp +++ b/include/mbgl/renderer/backend_scope.hpp @@ -22,10 +22,14 @@ public: static bool exists(); private: + void activate(); + void deactivate(); + BackendScope* priorScope; BackendScope* nextScope; RendererBackend& backend; const ScopeType scopeType; + bool activated = false; }; } // namespace mbgl diff --git a/include/mbgl/renderer/renderer_backend.hpp b/include/mbgl/renderer/renderer_backend.hpp index 9d967fd51b..a383329395 100644 --- a/include/mbgl/renderer/renderer_backend.hpp +++ b/include/mbgl/renderer/renderer_backend.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -81,4 +82,8 @@ private: friend class BackendScope; }; +MBGL_CONSTEXPR bool operator==(const RendererBackend& a, const RendererBackend& b) { + return &a == &b; +} + } // namespace mbgl -- cgit v1.2.1