fix for error with property getattro in recent commit which broke autocomp.

active base/bone & editbone were not converted to property srna
This commit is contained in:
Campbell Barton 2009-11-13 16:37:44 +00:00
parent 91352006c4
commit c1d0f9179d
3 changed files with 85 additions and 36 deletions

View File

@ -623,10 +623,64 @@ static void rna_def_edit_bone(BlenderRNA *brna)
RNA_define_verify_sdna(1);
}
/* armature.bones.* */
static void rna_def_armature_bones(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
PropertyRNA *prop;
// FunctionRNA *func;
// PropertyRNA *parm;
srna= RNA_def_struct(brna, "ArmatureBones", NULL);
RNA_def_struct_sdna(srna, "bArmature");
RNA_def_struct_ui_text(srna, "Armature Bones", "Collection of armature bones.");
RNA_def_property_srna(cprop, "ArmatureBones");
prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Bone");
RNA_def_property_pointer_sdna(prop, NULL, "act_bone");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Active Bone", "Armatures active bone.");
RNA_def_property_pointer_funcs(prop, NULL, "rna_Armature_act_bone_set", NULL);
/* todo, redraw */
// RNA_def_property_collection_active(prop, prop_act);
}
/* armature.bones.* */
static void rna_def_armature_edit_bones(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
PropertyRNA *prop;
// FunctionRNA *func;
// PropertyRNA *parm;
srna= RNA_def_struct(brna, "ArmatureEditBones", NULL);
RNA_def_struct_sdna(srna, "bArmature");
RNA_def_struct_ui_text(srna, "Armature EditBones", "Collection of armature edit bones.");
RNA_def_property_srna(cprop, "ArmatureEditBones");
prop= RNA_def_property(srna, "edit_bones", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "EditBone");
RNA_def_property_pointer_sdna(prop, NULL, "act_edbone");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Active EditBone", "Armatures active edit bone.");
//RNA_def_property_update(prop, 0, "rna_Armature_act_editbone_update");
RNA_def_property_pointer_funcs(prop, NULL, "rna_Armature_act_edit_bone_set", NULL);
/* todo, redraw */
// RNA_def_property_collection_active(prop, prop_act);
}
static void rna_def_armature(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop, *prop_act;
PropertyRNA *prop;
static EnumPropertyItem prop_drawtype_items[] = {
{ARM_OCTA, "OCTAHEDRAL", 0, "Octahedral", "Display bones as octahedral shape (default)."},
@ -666,34 +720,13 @@ static void rna_def_armature(BlenderRNA *brna)
RNA_def_property_collection_funcs(prop, 0, "rna_Armature_bones_next", 0, 0, 0, 0, 0);
RNA_def_property_struct_type(prop, "Bone");
RNA_def_property_ui_text(prop, "Bones", "");
{ /* Collection active property */
prop_act= RNA_def_property(srna, "bones__active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop_act, "Bone");
RNA_def_property_pointer_sdna(prop_act, NULL, "act_bone");
RNA_def_property_flag(prop_act, PROP_EDITABLE);
RNA_def_property_ui_text(prop_act, "Active Bone", "Armatures active bone.");
RNA_def_property_pointer_funcs(prop_act, NULL, "rna_Armature_act_bone_set", NULL);
/* todo, redraw */
// RNA_def_property_collection_active(prop, prop_act);
}
rna_def_armature_bones(brna, prop);
prop= RNA_def_property(srna, "edit_bones", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "edbo", NULL);
RNA_def_property_struct_type(prop, "EditBone");
RNA_def_property_ui_text(prop, "Edit Bones", "");
{ /* Collection active property */
prop_act= RNA_def_property(srna, "edit_bones__active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop_act, "EditBone");
RNA_def_property_pointer_sdna(prop_act, NULL, "act_edbone");
RNA_def_property_flag(prop_act, PROP_EDITABLE);
RNA_def_property_ui_text(prop_act, "Active EditBone", "Armatures active edit bone.");
//RNA_def_property_update(prop_act, 0, "rna_Armature_act_editbone_update");
RNA_def_property_pointer_funcs(prop_act, NULL, "rna_Armature_act_edit_bone_set", NULL);
// RNA_def_property_collection_active(prop, prop_act);
}
rna_def_armature_edit_bones(brna, prop);
/* Enum values */
// prop= RNA_def_property(srna, "rest_position", PROP_BOOLEAN, PROP_NONE);

View File

@ -2222,6 +2222,29 @@ static void rna_def_scene_objects(BlenderRNA *brna, PropertyRNA *cprop)
}
/* scene.bases.* */
static void rna_def_scene_bases(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
PropertyRNA *prop;
// FunctionRNA *func;
// PropertyRNA *parm;
srna= RNA_def_struct(brna, "SceneBases", NULL);
RNA_def_struct_sdna(srna, "Scene");
RNA_def_struct_ui_text(srna, "Scene Bases", "Collection of scene bases.");
RNA_def_property_srna(cprop, "SceneBases");
prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "ObjectBase");
RNA_def_property_pointer_sdna(prop, NULL, "basact");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Active Base", "Active object base in the scene.");
RNA_def_property_update(prop, NC_SCENE|ND_OB_ACTIVE, NULL);
}
void RNA_def_scene(BlenderRNA *brna)
{
StructRNA *srna;
@ -2274,16 +2297,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "base", NULL);
RNA_def_property_struct_type(prop, "ObjectBase");
RNA_def_property_ui_text(prop, "Bases", "");
{ /* Collection active property */
prop_act= RNA_def_property(srna, "bases__active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop_act, "ObjectBase");
RNA_def_property_pointer_sdna(prop_act, NULL, "basact");
RNA_def_property_flag(prop_act, PROP_EDITABLE);
RNA_def_property_ui_text(prop_act, "Active Base", "Active object base in the scene.");
RNA_def_property_update(prop_act, NC_SCENE|ND_OB_ACTIVE, NULL);
// RNA_def_property_collection_active(prop, prop_act);
}
rna_def_scene_bases(brna, prop);
prop= RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "base", NULL);

View File

@ -1494,14 +1494,16 @@ static PyObject *pyrna_prop_getattro( BPy_PropertyRNA *self, PyObject *pyname )
if(RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
if ((prop = RNA_struct_find_property(&r_ptr, name))) {
ret = pyrna_prop_to_py(&r_ptr, prop);
return ret;
}
else if ((func = RNA_struct_find_function(&r_ptr, name))) {
PyObject *self_collection= pyrna_struct_CreatePyObject(&r_ptr);
ret = pyrna_func_to_py((BPy_DummyPointerRNA *)self_collection, func);
Py_DECREF(self_collection);
}
return ret;
return ret;
}
}
}