summaryrefslogtreecommitdiff
path: root/include/mbgl/style
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-10-08 15:27:33 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-10-08 15:27:33 +0200
commit91f40daa6911f57f3dca534080241b46844c71b7 (patch)
tree30b7ae192785add4dbaa0ed4304faab6336079ef /include/mbgl/style
parent36b7bb0c0991b3c5c3a7d001139b120bee854484 (diff)
downloadqtlocation-mapboxgl-91f40daa6911f57f3dca534080241b46844c71b7.tar.gz
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
Diffstat (limited to 'include/mbgl/style')
-rw-r--r--include/mbgl/style/class_dictionary.hpp13
1 files changed, 9 insertions, 4 deletions
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<std::string, ClassID> store;
- static uint32_t offset;
+ std::unordered_map<std::string, ClassID> store = { { "", ClassID::Default } };
+ uint32_t offset = 0;
};
}