diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-15 01:42:51 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-15 01:59:31 +0300 |
commit | 4e46ed37fc5939d733001ba8ce17bd46e500839b (patch) | |
tree | 3c7a4c9f1d4a554dc885ebf707c4b01b23996fa7 /intern/cycles/render/nodes.cpp | |
parent | c29ed65f03c480022ec8d4b98355ffc0ca82fb80 (diff) |
Fix T64618: Cycles crash with point density texture on Windows
A better solution would be to not use the callback mechanism anymore for
cases like this where the dependency graph will free volume data, but
that would be a bigger refactor.
Diffstat (limited to 'intern/cycles/render/nodes.cpp')
-rw-r--r-- | intern/cycles/render/nodes.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 22b39701ef2..e4fa92fb1d7 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -263,13 +263,11 @@ ImageTextureNode::~ImageTextureNode() ShaderNode *ImageTextureNode::clone() const { - ImageTextureNode *node = new ImageTextureNode(*this); - node->image_manager = NULL; - node->slot = -1; - node->is_float = -1; - node->compress_as_srgb = false; - node->colorspace = colorspace; - return node; + /* Increase image user count for new node. */ + if (slot != -1) { + image_manager->add_image_user(slot); + } + return new ImageTextureNode(*this); } void ImageTextureNode::attributes(Shader *shader, AttributeRequestSet *attributes) @@ -448,13 +446,11 @@ EnvironmentTextureNode::~EnvironmentTextureNode() ShaderNode *EnvironmentTextureNode::clone() const { - EnvironmentTextureNode *node = new EnvironmentTextureNode(*this); - node->image_manager = NULL; - node->slot = -1; - node->is_float = -1; - node->compress_as_srgb = false; - node->colorspace = colorspace; - return node; + /* Increase image user count for new node. */ + if (slot != -1) { + image_manager->add_image_user(slot); + } + return new EnvironmentTextureNode(*this); } void EnvironmentTextureNode::attributes(Shader *shader, AttributeRequestSet *attributes) @@ -1481,10 +1477,13 @@ PointDensityTextureNode::~PointDensityTextureNode() ShaderNode *PointDensityTextureNode::clone() const { - PointDensityTextureNode *node = new PointDensityTextureNode(*this); - node->image_manager = NULL; - node->slot = -1; - return node; + /* Increase image user count for new node. We need to ensure to not call + * add_image again, to work around access of freed data on the Blender + * side. A better solution should be found to avoid this. */ + if (slot != -1) { + image_manager->add_image_user(slot); + } + return new PointDensityTextureNode(*this); } void PointDensityTextureNode::attributes(Shader *shader, AttributeRequestSet *attributes) |