[Bf-blender-cvs] [569e29c49c1] blender2.8: Fix RNA crash for objects without collection properties

Dalai Felinto noreply at git.blender.org
Thu Dec 14 23:17:58 CET 2017


Commit: 569e29c49c1162bd9ee9c0e0c7313ea4ee76c0d0
Author: Dalai Felinto
Date:   Thu Dec 14 20:17:00 2017 -0200
Branches: blender2.8
https://developer.blender.org/rB569e29c49c1162bd9ee9c0e0c7313ea4ee76c0d0

Fix RNA crash for objects without collection properties

This would happen if you tried to access the collection property for an object
that has not being evaluated by the depsgraph.

===================================================================

M	source/blender/makesrna/intern/rna_object.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index a153590f4ac..9301ed63adb 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -229,6 +229,15 @@ static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA
 	DEG_id_type_tag(bmain, ID_OB);
 }
 
+static void rna_Object_collection_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+	Object *ob = ptr->data;
+
+	if (ob->base_collection_properties != NULL) {
+		rna_iterator_listbase_begin(iter, &ob->base_collection_properties->data.group, NULL);
+	}
+}
+
 static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16])
 {
 	Object *ob = ptr->id.data;
@@ -2803,6 +2812,15 @@ static void rna_def_object(BlenderRNA *brna)
 
 	prop = RNA_def_property(srna, "collection_properties", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_collection_sdna(prop, NULL, "base_collection_properties->data.group", NULL);
+	RNA_def_property_collection_funcs(prop,
+	                                  "rna_Object_collection_properties_begin",
+	                                  NULL,
+	                                  NULL,
+	                                  NULL,
+	                                  NULL,
+	                                  NULL,
+	                                  NULL,
+	                                  NULL);
 	RNA_def_property_struct_type(prop, "LayerCollectionSettings");
 	RNA_def_property_ui_text(prop, "Collection Settings",
 	                         "Engine specific render settings to be overridden by collections");



More information about the Bf-blender-cvs mailing list