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.
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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'])
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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'])
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user