From 21ea4995585931ad54f51c1878c06c526c3355a5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 Aug 2022 22:56:54 +1000 Subject: Fix T100286: Crash accessing freed depsgraph object instances Invalidate depsgraph.object_instances when freed, this resolves a crash when accessing the object instances after iteration has finished. Unlike most other collections, object_instances is only valid while the iterator is in-memory. The Python/RNA API needs to inline int/string collection lookups so the Python instance can be created before the iterator ends. Reviewed By: mont29, sergey Ref D15755 --- source/blender/makesrna/intern/rna_access.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/blender/makesrna/intern/rna_access.c') diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 04707c01d6b..56cbcb2a7f2 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -4080,6 +4080,20 @@ int RNA_property_collection_lookup_index(PointerRNA *ptr, return -1; } +bool RNA_property_collection_lookup_int_has_fn(PropertyRNA *prop) +{ + BLI_assert(RNA_property_type(prop) == PROP_COLLECTION); + CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)rna_ensure_property(prop); + return cprop->lookupint != NULL; +} + +bool RNA_property_collection_lookup_string_has_fn(PropertyRNA *prop) +{ + BLI_assert(RNA_property_type(prop) == PROP_COLLECTION); + CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)rna_ensure_property(prop); + return cprop->lookupstring != NULL; +} + int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, -- cgit v1.2.3