* Object.create_dupli_list, Object.free_dupli_list tweaking
* Defined custom "get" function for DupliObject.object Accessing Object.dupli_list[N].object produces a crash.
This commit is contained in:
@@ -364,6 +364,14 @@ static void rna_GameObjectSettings_state_set(PointerRNA *ptr, const int *values)
|
||||
}
|
||||
}
|
||||
|
||||
static PointerRNA rna_DupliObject_object_get(PointerRNA *ptr)
|
||||
{
|
||||
DupliObject *dob= (DupliObject*)ptr->data;
|
||||
PointerRNA newptr;
|
||||
RNA_pointer_create(&dob->ob->id, &RNA_Object, dob->ob, &newptr);
|
||||
return newptr;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void rna_def_vertex_group(BlenderRNA *brna)
|
||||
@@ -1167,8 +1175,9 @@ static void rna_def_dupli_object(BlenderRNA *brna)
|
||||
/* RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA); */
|
||||
|
||||
prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_pointer_sdna(prop, NULL, "ob");
|
||||
RNA_def_property_struct_type(prop, "Object");
|
||||
RNA_def_property_pointer_sdna(prop, NULL, "ob");
|
||||
RNA_def_property_pointer_funcs(prop, "rna_DupliObject_object_get", NULL, NULL);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_ui_text(prop, "Object", "Object this DupliObject represents.");
|
||||
|
||||
|
||||
@@ -108,20 +108,19 @@ static void rna_Object_create_duplilist(Object *ob, bContext *C, ReportList *rep
|
||||
return;
|
||||
}
|
||||
|
||||
sce= CTX_data_scene(C);
|
||||
|
||||
RNA_id_pointer_create(&ob->id, &obptr);
|
||||
|
||||
if (!(prop= RNA_struct_find_property(&obptr, OBJECT_API_PROP_DUPLILIST))) {
|
||||
// hint: all Objects will now have this property defined
|
||||
prop= RNA_def_collection_runtime(obptr.type, OBJECT_API_PROP_DUPLILIST, &RNA_DupliObject, "Dupli list", "List of object's duplis");
|
||||
prop= RNA_def_collection_runtime(obptr.type, OBJECT_API_PROP_DUPLILIST, &RNA_DupliObject, "Dupli list", "");
|
||||
}
|
||||
|
||||
RNA_property_collection_clear(&obptr, prop);
|
||||
sce= CTX_data_scene(C);
|
||||
ob->duplilist= object_duplilist(sce, ob);
|
||||
|
||||
for(dob= (DupliObject*)ob->duplilist->first; dob; dob= dob->next) {
|
||||
RNA_pointer_create(NULL, &RNA_Object, dob, &dobptr);
|
||||
RNA_pointer_create(NULL, &RNA_DupliObject, dob, &dobptr);
|
||||
RNA_property_collection_add(&obptr, prop, &dobptr);
|
||||
dob = dob->next;
|
||||
}
|
||||
@@ -143,8 +142,10 @@ static void rna_Object_free_duplilist(Object *ob, ReportList *reports)
|
||||
|
||||
RNA_property_collection_clear(&obptr, prop);
|
||||
|
||||
free_object_duplilist(ob->duplilist);
|
||||
ob->duplilist= NULL;
|
||||
if (ob->duplilist) {
|
||||
free_object_duplilist(ob->duplilist);
|
||||
ob->duplilist= NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user