diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-06-12 10:55:34 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-06-12 15:30:50 +0300 |
commit | 3263e5e8817c38dc795a999d22cd2443a329f7b5 (patch) | |
tree | f609fc94e2d8f762798a0d7bce8a629870b766f4 /source/blender/depsgraph/intern/depsgraph_query_iter.cc | |
parent | abdea5754e641a3b66171c90c2ee1ac151225d10 (diff) |
Depsgraph: Set temp object to invalid state as soon as it becomes inaccessible
Diffstat (limited to 'source/blender/depsgraph/intern/depsgraph_query_iter.cc')
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_query_iter.cc | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc index 712ada44b7e..1dd6f8b6a0b 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc @@ -60,10 +60,29 @@ extern "C" { # include "intern/eval/deg_eval_copy_on_write.h" #endif +// If defined, all working data will be set to an invalid state, helping +// to catch issues when areas accessing data which is considered to be no +// longer available. +#undef INVALIDATE_WORK_DATA + +#ifndef NDEBUG +# define INVALIDATE_WORK_DATA +#endif + /* ************************ DEG ITERATORS ********************* */ namespace { +void deg_invalidate_iterator_work_data(DEGObjectIterData *data) +{ +#ifdef INVALIDATE_WORK_DATA + BLI_assert(data != NULL); + memset(&data->temp_dupli_object, 0xff, sizeof(data->temp_dupli_object)); +#else + (void) data; +#endif +} + void verify_id_proeprties_freed(DEGObjectIterData *data) { if (data->dupli_object_current == NULL) { @@ -219,6 +238,7 @@ void DEG_iterator_objects_begin(BLI_Iterator *iter, DEGObjectIterData *data) data->visibility_check = (eval_mode == DAG_EVAL_RENDER) ? OB_VISIBILITY_CHECK_FOR_RENDER : OB_VISIBILITY_CHECK_FOR_VIEWPORT; + deg_invalidate_iterator_work_data(data); DEG::IDDepsNode *id_node = deg_graph->id_nodes[data->id_node_index]; deg_iterator_objects_step(iter, id_node); @@ -246,6 +266,7 @@ void DEG_iterator_objects_next(BLI_Iterator *iter) data->dupli_list = NULL; data->dupli_object_next = NULL; data->dupli_object_current = NULL; + deg_invalidate_iterator_work_data(data); } } @@ -262,18 +283,13 @@ void DEG_iterator_objects_next(BLI_Iterator *iter) void DEG_iterator_objects_end(BLI_Iterator *iter) { -#ifndef NDEBUG DEGObjectIterData *data = (DEGObjectIterData *)iter->data; - - if (data) { + if (data != NULL) { /* Force crash in case the iterator data is referenced and accessed down * the line. (T51718) */ - memset(&data->temp_dupli_object, 0xff, sizeof(data->temp_dupli_object)); + deg_invalidate_iterator_work_data(data); } -#else - (void) iter; -#endif } /* ************************ DEG ID ITERATOR ********************* */ |