diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-01-05 19:18:02 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-01-05 19:18:02 +0300 |
commit | 5d564da3b66b541e6295a899eae05e43b479def2 (patch) | |
tree | 5578e7519267120396f745be5813b6a1a3fb9845 /intern/cycles/render | |
parent | 0b78b8f1675f6c0f230cf63100b7aa0ee6baf05d (diff) |
Cycles: Fix memory leak in shader graph when bump graph is used
Diffstat (limited to 'intern/cycles/render')
-rw-r--r-- | intern/cycles/render/graph.cpp | 13 | ||||
-rw-r--r-- | intern/cycles/render/graph.h | 1 |
2 files changed, 11 insertions, 3 deletions
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp index 852aaca5ad5..32c176949ed 100644 --- a/intern/cycles/render/graph.cpp +++ b/intern/cycles/render/graph.cpp @@ -210,8 +210,7 @@ ShaderGraph::ShaderGraph() ShaderGraph::~ShaderGraph() { - foreach(ShaderNode *node, nodes) - delete node; + clear_nodes(); } ShaderNode *ShaderGraph::add(ShaderNode *node) @@ -240,7 +239,7 @@ ShaderGraph *ShaderGraph::copy() copy_nodes(nodes_all, nodes_copy); /* add nodes (in same order, so output is still first) */ - newgraph->nodes.clear(); + newgraph->clear_nodes(); foreach(ShaderNode *node, nodes) newgraph->add(nodes_copy[node]); @@ -354,6 +353,14 @@ void ShaderGraph::find_dependencies(ShaderNodeSet& dependencies, ShaderInput *in } } +void ShaderGraph::clear_nodes() +{ + foreach(ShaderNode *node, nodes) { + delete node; + } + nodes.clear(); +} + void ShaderGraph::copy_nodes(ShaderNodeSet& nodes, ShaderNodeMap& nnodemap) { /* copy a set of nodes, and the links between them. the assumption is diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h index 0382cbcfa18..214199a1c52 100644 --- a/intern/cycles/render/graph.h +++ b/intern/cycles/render/graph.h @@ -323,6 +323,7 @@ protected: typedef pair<ShaderNode* const, ShaderNode*> NodePair; void find_dependencies(ShaderNodeSet& dependencies, ShaderInput *input); + void clear_nodes(); void copy_nodes(ShaderNodeSet& nodes, ShaderNodeMap& nnodemap); void break_cycles(ShaderNode *node, vector<bool>& visited, vector<bool>& on_stack); |