diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-02-23 13:58:27 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-02-23 14:01:16 +0300 |
commit | 48ed9fcb78275cb82f844ed91f9fe4d15d2570bd (patch) | |
tree | 2eadfc536057849ff3f2af4beb2bb1ae744ca3bc /source/blender/makesrna/intern/rna_nodetree.c | |
parent | 9c68ffc3b4d26a2cc571ee1a55482dbc447c7e80 (diff) |
Fix memory leak in point density
The issue was happening when having unconnected point density which
will cache data but will not free it because there's no actual call
to the actual sampling.
Now the idea is to make sure cache is zeroed on file load and undo
and then caching via RNA will free the data if any exists. This could
leave us with a single copy of cache in the node if it's not used,
but it's quite small amount of memory and it's not leaking.
Diffstat (limited to 'source/blender/makesrna/intern/rna_nodetree.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 50ad7a4ceb2..7561a7405f7 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -3045,8 +3045,11 @@ void rna_ShaderNodePointDensity_density_cache(bNode *self, return; } + /* Make sure there's no cached data. */ + BKE_texture_pointdensity_free_data(pd); + RE_point_density_free(pd); + /* Create PointDensity structure from node for sampling. */ - memset(pd, 0, sizeof(*pd)); BKE_texture_pointdensity_init_data(pd); pd->object = (Object *)self->id; pd->radius = shader_point_density->radius; @@ -3098,6 +3101,7 @@ void rna_ShaderNodePointDensity_density_calc(bNode *self, /* We're done, time to clean up. */ BKE_texture_pointdensity_free_data(pd); + memset(pd, 0, sizeof(*pd)); } void rna_ShaderNodePointDensity_density_minmax(bNode *self, |