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 | |
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.
21 files changed, 37 insertions, 11 deletions
diff --git a/release/scripts/ui/buttons_data_armature.py b/release/scripts/ui/buttons_data_armature.py index db635be763c..75264f5d7ec 100644 --- a/release/scripts/ui/buttons_data_armature.py +++ b/release/scripts/ui/buttons_data_armature.py @@ -10,6 +10,7 @@ class DataButtonsPanel(bpy.types.Panel): return context.armature class DATA_PT_context_arm(DataButtonsPanel): + bl_label = "" bl_show_header = False def draw(self, context): diff --git a/release/scripts/ui/buttons_data_bone.py b/release/scripts/ui/buttons_data_bone.py index a3ac86fa841..706c418d0ce 100644 --- a/release/scripts/ui/buttons_data_bone.py +++ b/release/scripts/ui/buttons_data_bone.py @@ -10,6 +10,7 @@ class BoneButtonsPanel(bpy.types.Panel): return (context.bone or context.edit_bone) class BONE_PT_context_bone(BoneButtonsPanel): + bl_label = "" bl_show_header = False def draw(self, context): diff --git a/release/scripts/ui/buttons_data_camera.py b/release/scripts/ui/buttons_data_camera.py index c76d2633a51..1321e42b97d 100644 --- a/release/scripts/ui/buttons_data_camera.py +++ b/release/scripts/ui/buttons_data_camera.py @@ -10,6 +10,7 @@ class DataButtonsPanel(bpy.types.Panel): return context.camera class DATA_PT_context_camera(DataButtonsPanel): + bl_label = "" bl_show_header = False def draw(self, context): diff --git a/release/scripts/ui/buttons_data_curve.py b/release/scripts/ui/buttons_data_curve.py index e86af9bf3ab..90d84dc09ed 100644 --- a/release/scripts/ui/buttons_data_curve.py +++ b/release/scripts/ui/buttons_data_curve.py @@ -25,6 +25,7 @@ class DataButtonsPanelActive(DataButtonsPanel): return (curve and curve.active_spline) class DATA_PT_context_curve(DataButtonsPanel): + bl_label = "" bl_show_header = False def draw(self, context): diff --git a/release/scripts/ui/buttons_data_lamp.py b/release/scripts/ui/buttons_data_lamp.py index 74c4ba012df..0d384701029 100644 --- a/release/scripts/ui/buttons_data_lamp.py +++ b/release/scripts/ui/buttons_data_lamp.py @@ -16,6 +16,7 @@ class DATA_PT_preview(DataButtonsPanel): self.layout.template_preview(context.lamp) class DATA_PT_context_lamp(DataButtonsPanel): + bl_label = "" bl_show_header = False def draw(self, context): diff --git a/release/scripts/ui/buttons_data_lattice.py b/release/scripts/ui/buttons_data_lattice.py index 3272e1ccf55..505ea6e42e9 100644 --- a/release/scripts/ui/buttons_data_lattice.py +++ b/release/scripts/ui/buttons_data_lattice.py @@ -10,6 +10,7 @@ class DataButtonsPanel(bpy.types.Panel): return context.lattice class DATA_PT_context_lattice(DataButtonsPanel): + bl_label = "" bl_show_header = False def draw(self, context): diff --git a/release/scripts/ui/buttons_data_mesh.py b/release/scripts/ui/buttons_data_mesh.py index f0120b58c6d..2ed52206d7e 100644 --- a/release/scripts/ui/buttons_data_mesh.py +++ b/release/scripts/ui/buttons_data_mesh.py @@ -10,6 +10,7 @@ class DataButtonsPanel(bpy.types.Panel): return context.mesh class DATA_PT_context_mesh(DataButtonsPanel): + bl_label = "" bl_show_header = False def draw(self, context): diff --git a/release/scripts/ui/buttons_data_metaball.py b/release/scripts/ui/buttons_data_metaball.py index bf937f212d9..ebb5efb40ca 100644 --- a/release/scripts/ui/buttons_data_metaball.py +++ b/release/scripts/ui/buttons_data_metaball.py @@ -9,6 +9,7 @@ class DataButtonsPanel(bpy.types.Panel): return context.meta_ball class DATA_PT_context_metaball(DataButtonsPanel): + bl_label = "" bl_show_header = False def draw(self, context): diff --git a/release/scripts/ui/buttons_data_text.py b/release/scripts/ui/buttons_data_text.py index 9b8e1e4d984..49847863d7c 100644 --- a/release/scripts/ui/buttons_data_text.py +++ b/release/scripts/ui/buttons_data_text.py @@ -10,6 +10,7 @@ class DataButtonsPanel(bpy.types.Panel): return (context.object and context.object.type == 'TEXT' and context.curve) class DATA_PT_context_text(DataButtonsPanel): + bl_label = "" bl_show_header = False def draw(self, context): @@ -171,7 +172,7 @@ class DATA_PT_textboxes(DataButtonsPanel): col.itemR(box, "x", text="X") col.itemR(box, "y", text="Y") -bpy.types.register(DATA_PT_context_text) +bpy.types.register(DATA_PT_context_text) bpy.types.register(DATA_PT_shape_text) bpy.types.register(DATA_PT_geometry_text) bpy.types.register(DATA_PT_font) diff --git a/release/scripts/ui/buttons_game.py b/release/scripts/ui/buttons_game.py index 2a1e6adee5b..77581884515 100644 --- a/release/scripts/ui/buttons_game.py +++ b/release/scripts/ui/buttons_game.py @@ -330,6 +330,7 @@ class WorldButtonsPanel(bpy.types.Panel): return (rd.engine == 'BLENDER_GAME') class WORLD_PT_game_context_world(WorldButtonsPanel): + bl_label = "" bl_show_header = False def poll(self, context): diff --git a/release/scripts/ui/buttons_material.py b/release/scripts/ui/buttons_material.py index c83f4a65209..af95eec9a68 100644 --- a/release/scripts/ui/buttons_material.py +++ b/release/scripts/ui/buttons_material.py @@ -32,6 +32,7 @@ class MATERIAL_PT_preview(MaterialButtonsPanel): self.layout.template_preview(context.material) class MATERIAL_PT_context_material(MaterialButtonsPanel): + bl_label = "" bl_show_header = False COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME']) diff --git a/release/scripts/ui/buttons_object.py b/release/scripts/ui/buttons_object.py index 37ecf83d846..213fbf17dd6 100644 --- a/release/scripts/ui/buttons_object.py +++ b/release/scripts/ui/buttons_object.py @@ -7,6 +7,7 @@ class ObjectButtonsPanel(bpy.types.Panel): bl_context = "object" class OBJECT_PT_context_object(ObjectButtonsPanel): + bl_label = "" bl_show_header = False def draw(self, context): diff --git a/release/scripts/ui/buttons_particle.py b/release/scripts/ui/buttons_particle.py index 8ab31df7543..ad9a82c6824 100644 --- a/release/scripts/ui/buttons_particle.py +++ b/release/scripts/ui/buttons_particle.py @@ -24,6 +24,7 @@ class ParticleButtonsPanel(bpy.types.Panel): return particle_panel_poll(context) class PARTICLE_PT_particles(ParticleButtonsPanel): + bl_label = "" bl_show_header = False def poll(self, context): diff --git a/release/scripts/ui/buttons_texture.py b/release/scripts/ui/buttons_texture.py index cb5bca9e26a..3426a879cca 100644 --- a/release/scripts/ui/buttons_texture.py +++ b/release/scripts/ui/buttons_texture.py @@ -1,4 +1,3 @@ - import bpy def active_node_mat(mat): @@ -51,6 +50,7 @@ class TEXTURE_PT_preview(TextureButtonsPanel): layout.template_preview(tex, slot=slot) class TEXTURE_PT_context_texture(TextureButtonsPanel): + bl_label = "" bl_show_header = False def poll(self, context): diff --git a/release/scripts/ui/buttons_world.py b/release/scripts/ui/buttons_world.py index b0bb27518d4..cfe2410595c 100644 --- a/release/scripts/ui/buttons_world.py +++ b/release/scripts/ui/buttons_world.py @@ -19,6 +19,7 @@ class WORLD_PT_preview(WorldButtonsPanel): self.layout.template_preview(context.world) class WORLD_PT_context_world(WorldButtonsPanel): + bl_label = "" bl_show_header = False COMPAT_ENGINES = set(['BLENDER_RENDER']) diff --git a/release/scripts/ui/space_info.py b/release/scripts/ui/space_info.py index 58ba96e0181..bf7d30c461d 100644 --- a/release/scripts/ui/space_info.py +++ b/release/scripts/ui/space_info.py @@ -96,12 +96,14 @@ dynamic_menu.setup(INFO_MT_file_more) ''' class INFO_MT_file_import(dynamic_menu.DynMenu): + bl_idname = "INFO_MT_file_import" bl_label = "Import" def draw(self, context): self.layout.itemO("WM_OT_collada_import", text="COLLADA (.dae)...") class INFO_MT_file_export(dynamic_menu.DynMenu): + bl_idname = "INFO_MT_file_export" bl_label = "Export" def draw(self, context): @@ -124,6 +126,7 @@ class INFO_MT_file_external_data(bpy.types.Menu): layout.itemO("file.find_missing_files") class INFO_MT_mesh_add(dynamic_menu.DynMenu): + bl_idname = "INFO_MT_mesh_add" bl_label = "Mesh" def draw(self, context): layout = self.layout diff --git a/release/scripts/ui/space_userpref.py b/release/scripts/ui/space_userpref.py index b5fdf2fcea0..ef85a608d17 100644 --- a/release/scripts/ui/space_userpref.py +++ b/release/scripts/ui/space_userpref.py @@ -24,7 +24,9 @@ class USERPREF_MT_view(bpy.types.Menu): layout = self.layout class USERPREF_PT_tabs(bpy.types.Panel): + bl_label = "" bl_space_type = 'USER_PREFERENCES' + bl_region_type = 'WINDOW' bl_show_header = False def draw(self, context): @@ -37,6 +39,7 @@ class USERPREF_PT_tabs(bpy.types.Panel): class USERPREF_PT_interface(bpy.types.Panel): bl_space_type = 'USER_PREFERENCES' bl_label = "Interface" + bl_region_type = 'WINDOW' bl_show_header = False def poll(self, context): @@ -121,6 +124,7 @@ class USERPREF_PT_interface(bpy.types.Panel): class USERPREF_PT_edit(bpy.types.Panel): bl_space_type = 'USER_PREFERENCES' bl_label = "Edit" + bl_region_type = 'WINDOW' bl_show_header = False def poll(self, context): @@ -224,6 +228,7 @@ class USERPREF_PT_edit(bpy.types.Panel): class USERPREF_PT_system(bpy.types.Panel): bl_space_type = 'USER_PREFERENCES' bl_label = "System" + bl_region_type = 'WINDOW' bl_show_header = False def poll(self, context): @@ -315,6 +320,7 @@ class USERPREF_PT_system(bpy.types.Panel): class USERPREF_PT_file(bpy.types.Panel): bl_space_type = 'USER_PREFERENCES' bl_label = "Files" + bl_region_type = 'WINDOW' bl_show_header = False def poll(self, context): @@ -381,6 +387,7 @@ class USERPREF_PT_file(bpy.types.Panel): class USERPREF_PT_input(bpy.types.Panel): bl_space_type = 'USER_PREFERENCES' bl_label = "Input" + bl_region_type = 'WINDOW' bl_show_header = False def poll(self, context): diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index f0d1a0dcc6c..d0f60c98a1c 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -886,6 +886,7 @@ class VIEW3D_MT_edit_mesh_edges(bpy.types.Menu): class VIEW3D_MT_edit_mesh_faces(dynamic_menu.DynMenu): bl_label = "Faces" + bl_idname = "VIEW3D_MT_edit_mesh_faces" def draw(self, context): layout = self.layout 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; } |