diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-10-31 21:48:58 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-10-31 21:48:58 +0300 |
commit | af72bb50ae41f5ba1f9f5b2310b2aee77907fecf (patch) | |
tree | eac2c8df182ba238758fb51b2292212326e1c7ac /source | |
parent | e4881eef529262ec131ab22688e44fb9af2f0bb9 (diff) |
improved class validation, variables defined by the rna interface as non-optional could fail silently when absent in the class. Set these to PROP_REGISTER_OPTIONAL and raise an error when others are not found.
last commit broke povray too.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesrna/intern/rna_render.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ui.c | 8 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 7 |
3 files changed, 10 insertions, 9 deletions
diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index a67831715a2..3505253b60f 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -269,11 +269,11 @@ static void rna_def_render_engine(BlenderRNA *brna) /* registration */ RNA_define_verify_sdna(0); - prop= RNA_def_property(srna, "idname", PROP_STRING, PROP_NONE); + prop= RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->idname"); RNA_def_property_flag(prop, PROP_REGISTER); - prop= RNA_def_property(srna, "label", PROP_STRING, PROP_NONE); + prop= RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->name"); RNA_def_property_flag(prop, PROP_REGISTER); diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 34b50e1b3ea..1bb7fe720a6 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -592,7 +592,6 @@ static void rna_def_panel(BlenderRNA *brna) /* registration */ prop= RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_REGISTER_OPTIONAL); RNA_def_property_string_sdna(prop, NULL, "type->idname"); RNA_def_property_flag(prop, PROP_REGISTER); @@ -612,15 +611,15 @@ static void rna_def_panel(BlenderRNA *brna) prop= RNA_def_property(srna, "bl_context", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->context"); - RNA_def_property_flag(prop, PROP_REGISTER); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); /* should this be optional? - Campbell */ prop= RNA_def_property(srna, "bl_default_closed", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "type->flag", PNL_DEFAULT_CLOSED); - RNA_def_property_flag(prop, PROP_REGISTER); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); prop= RNA_def_property(srna, "bl_show_header", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "type->flag", PNL_NO_HEADER); - RNA_def_property_flag(prop, PROP_REGISTER); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); } static void rna_def_header(BlenderRNA *brna) @@ -693,7 +692,6 @@ static void rna_def_menu(BlenderRNA *brna) /* registration */ prop= RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_REGISTER_OPTIONAL); RNA_def_property_string_sdna(prop, NULL, "type->idname"); RNA_def_property_flag(prop, PROP_REGISTER); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index f12c7b55b0e..f914c3cacea 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -3194,7 +3194,7 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun PyObject *item, *fitem; PyObject *py_arg_count; int i, flag, arg_count, func_arg_count; - char *identifier; + const char *identifier; if (base_class) { if (!PyObject_IsSubclass(py_class, base_class)) { @@ -3269,6 +3269,8 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun item = PyObject_GetAttrString(py_class, identifier); if (item==NULL) { + + /* Sneaky workaround to use the class name as the bl_idname */ if(strcmp(identifier, "bl_idname") == 0) { item= PyObject_GetAttrString(py_class, "__name__"); @@ -3280,7 +3282,8 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun } } - if (item==NULL && (flag & PROP_REGISTER_OPTIONAL)==0) { + + if (item == NULL && (((flag & PROP_REGISTER_OPTIONAL) != PROP_REGISTER_OPTIONAL))) { PyErr_Format( PyExc_AttributeError, "expected %.200s class to have an \"%.200s\" attribute", class_type, identifier); return -1; } |