From 91f40daa6911f57f3dca534080241b46844c71b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 8 Oct 2014 15:27:33 +0200 Subject: don't do concurrent access to a static member variable in situations where the renderer is used from multiple threads, this causes memory corruption. fixes mapbox/node-mapbox-gl-native#7 --- include/mbgl/style/class_dictionary.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/mbgl/style/class_dictionary.hpp b/include/mbgl/style/class_dictionary.hpp index c7f9c6a284..ecf80be3e3 100644 --- a/include/mbgl/style/class_dictionary.hpp +++ b/include/mbgl/style/class_dictionary.hpp @@ -14,17 +14,22 @@ enum class ClassID : uint32_t { }; class ClassDictionary { +private: + ClassDictionary(); + public: + static ClassDictionary &Get(); + // Returns an ID for a class name. If the class name does not yet have an ID, one is // auto-generated and stored for future reference. - static ClassID Lookup(const std::string &class_name); + ClassID lookup(const std::string &class_name); // Returns either Fallback, Default or Named, depending on the type of the class id. - static ClassID Normalize(ClassID id); + ClassID normalize(ClassID id); private: - static std::unordered_map store; - static uint32_t offset; + std::unordered_map store = { { "", ClassID::Default } }; + uint32_t offset = 0; }; } -- cgit v1.2.1