diff options
author | Julian Eisel <julian@blender.org> | 2020-08-07 14:04:31 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-08-07 14:04:31 +0300 |
commit | 0d2d4a6d4a75ac38c41f872c88255eab70e88ab7 (patch) | |
tree | b7a7518af86dddba48e05a98b3c2be55e8804721 /source/blender/depsgraph/intern/depsgraph_registry.cc | |
parent | 9b416c66fb714bdfd15a481489dbf650d0f389ea (diff) | |
parent | cfc6f9eb18e701f5be601b95c45004e8cf7fbc81 (diff) |
Merge branch 'master' into temp-ui-button-type-refactortemp-ui-button-type-refactor
Diffstat (limited to 'source/blender/depsgraph/intern/depsgraph_registry.cc')
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_registry.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph_registry.cc b/source/blender/depsgraph/intern/depsgraph_registry.cc index 6bfd2e881cc..623702ee3ae 100644 --- a/source/blender/depsgraph/intern/depsgraph_registry.cc +++ b/source/blender/depsgraph/intern/depsgraph_registry.cc @@ -30,29 +30,35 @@ namespace blender { namespace deg { -static Map<Main *, VectorSet<Depsgraph *>> g_graph_registry; +using GraphRegistry = Map<Main *, VectorSet<Depsgraph *>>; +static GraphRegistry &get_graph_registry() +{ + static GraphRegistry graph_registry; + return graph_registry; +} void register_graph(Depsgraph *depsgraph) { Main *bmain = depsgraph->bmain; - g_graph_registry.lookup_or_add_default(bmain).add_new(depsgraph); + get_graph_registry().lookup_or_add_default(bmain).add_new(depsgraph); } void unregister_graph(Depsgraph *depsgraph) { Main *bmain = depsgraph->bmain; - VectorSet<Depsgraph *> &graphs = g_graph_registry.lookup(bmain); + GraphRegistry &graph_registry = get_graph_registry(); + VectorSet<Depsgraph *> &graphs = graph_registry.lookup(bmain); graphs.remove(depsgraph); // If this was the last depsgraph associated with the main, remove the main entry as well. if (graphs.is_empty()) { - g_graph_registry.remove(bmain); + graph_registry.remove(bmain); } } Span<Depsgraph *> get_all_registered_graphs(Main *bmain) { - VectorSet<Depsgraph *> *graphs = g_graph_registry.lookup_ptr(bmain); + VectorSet<Depsgraph *> *graphs = get_graph_registry().lookup_ptr(bmain); if (graphs != nullptr) { return *graphs; } |