diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-01-30 18:05:43 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-01-30 18:07:08 +0300 |
commit | dbed11d272a2ed6a430c1e26ebbdb566860dbcd1 (patch) | |
tree | f84052f43768b53e7f175b744f9b51d3156dad5e /source | |
parent | 0d64857c3f2364349475728958fac211b0bad5a2 (diff) |
Fix FOREACH_OBJECT_RENDERABLE using stack data
Since 30a966a7262308 when I removed the recursion, the code was still relying
on stack data. This would crash in release often, and it should crash always.
Big thanks to Sergey Sharybin for spotting the issue.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_layer.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/layer.c | 18 |
2 files changed, 12 insertions, 10 deletions
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h index b605b208f66..10026210d0c 100644 --- a/source/blender/blenkernel/BKE_layer.h +++ b/source/blender/blenkernel/BKE_layer.h @@ -29,6 +29,8 @@ #include "BKE_collection.h" +#include "DNA_scene_types.h" + #ifdef __cplusplus extern "C" { #endif @@ -263,6 +265,8 @@ void BKE_visible_bases_iterator_end(BLI_Iterator *iter); typedef struct ObjectsRenderableIteratorData { struct Scene *scene; + struct Base base_temp; + struct Scene scene_temp; struct { struct ViewLayer *view_layer; diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index d9794ecbd69..9332bafb256 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -1982,8 +1982,8 @@ void BKE_renderable_objects_iterator_begin(BLI_Iterator *iter, void *data_in) ViewLayer *view_layer = data->scene->view_layers.first; data->iter.view_layer = view_layer; - Base base = {(Base *)view_layer->object_bases.first, NULL}; - data->iter.base = &base; + data->base_temp.next = view_layer->object_bases.first; + data->iter.base = &data->base_temp; data->iter.set = NULL; @@ -2023,25 +2023,23 @@ void BKE_renderable_objects_iterator_next(BLI_Iterator *iter) while ((data->iter.view_layer = data->iter.view_layer->next)) { ViewLayer *view_layer = data->iter.view_layer; if (view_layer->flag & VIEW_LAYER_RENDER) { - - Base base_iter = {(Base *)view_layer->object_bases.first, NULL}; - data->iter.base = &base_iter; + data->base_temp.next = view_layer->object_bases.first; + data->iter.base = &data->base_temp; return; } } /* Setup the "set" for the next iteration. */ - Scene scene = {.set = data->scene}; - data->iter.set = &scene; + data->scene_temp.set = data->scene; + data->iter.set = &data->scene_temp; return; } /* Look for an object in the next set. */ while ((data->iter.set = data->iter.set->set)) { ViewLayer *view_layer = BKE_view_layer_from_scene_get(data->iter.set); - - Base base_iter = {(Base *)view_layer->object_bases.first, NULL}; - data->iter.base = &base_iter; + data->base_temp.next = view_layer->object_bases.first; + data->iter.base = &data->base_temp; return; } |