Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/makesrna/intern/rna_depsgraph.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c
index 6f930d7569a..1a2ecc11505 100644
--- a/source/blender/makesrna/intern/rna_depsgraph.c
+++ b/source/blender/makesrna/intern/rna_depsgraph.c
@@ -301,6 +301,7 @@ typedef struct RNA_Depsgraph_Instances_Iterator
{
BLI_Iterator iterators[2];
DEGObjectIterData deg_data[2];
+ DupliObject dupli_object_current[2];
int counter;
} RNA_Depsgraph_Instances_Iterator;
@@ -331,6 +332,13 @@ static void rna_Depsgraph_object_instances_next(CollectionPropertyIterator *iter
di_it->iterators[di_it->counter % 2].data = &di_it->deg_data[di_it->counter % 2];
DEG_iterator_objects_next(&di_it->iterators[di_it->counter % 2]);
+ /* Dupli_object_current is also temp memory generated during the iterations,
+ * it may be freed when last item has been iterated, so we have same issue as with the iterator itself:
+ * we need to keep a local copy, which memory remains valid a bit longer, for python accesses to work. */
+ if (di_it->deg_data[di_it->counter % 2].dupli_object_current != NULL) {
+ di_it->dupli_object_current[di_it->counter % 2] = *di_it->deg_data[di_it->counter % 2].dupli_object_current;
+ di_it->deg_data[di_it->counter % 2].dupli_object_current = &di_it->dupli_object_current[di_it->counter % 2];
+ }
iter->valid = di_it->iterators[di_it->counter % 2].valid;
}