Skip to content
Snippets Groups Projects
Commit 92cfcccf authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Rigify: avoid AttributeErrors when there is no active object

`context.object` can be None, so a poll function should not access
`context.object.type` without prior check.
parent 9a9832d5
Branches
Tags
No related merge requests found
......@@ -68,6 +68,8 @@ class DATA_PT_rigify_buttons(bpy.types.Panel):
@classmethod
def poll(cls, context):
if not context.object:
return False
return context.object.type == 'ARMATURE' and context.active_object.data.get("rig_id") is None
def draw(self, context):
......@@ -197,6 +199,8 @@ class DATA_PT_rigify_layer_names(bpy.types.Panel):
@classmethod
def poll(cls, context):
if not context.object:
return False
return context.object.type == 'ARMATURE' and context.active_object.data.get("rig_id") is None
def draw(self, context):
......@@ -280,7 +284,7 @@ class DATA_OT_rigify_add_bone_groups(bpy.types.Operator):
@classmethod
def poll(cls, context):
return context.object.type == 'ARMATURE'
return context.object and context.object.type == 'ARMATURE'
def execute(self, context):
obj = context.object
......@@ -323,7 +327,7 @@ class DATA_OT_rigify_use_standard_colors(bpy.types.Operator):
@classmethod
def poll(cls, context):
return context.object.type == 'ARMATURE'
return context.object and context.object.type == 'ARMATURE'
def execute(self, context):
obj = context.object
......@@ -350,7 +354,7 @@ class DATA_OT_rigify_apply_selection_colors(bpy.types.Operator):
@classmethod
def poll(cls, context):
return context.object.type == 'ARMATURE'
return context.object and context.object.type == 'ARMATURE'
def execute(self, context):
obj = context.object
......@@ -374,7 +378,7 @@ class DATA_OT_rigify_bone_group_add(bpy.types.Operator):
@classmethod
def poll(cls, context):
return context.object.type == 'ARMATURE'
return context.object and context.object.type == 'ARMATURE'
def execute(self, context):
obj = context.object
......@@ -428,7 +432,7 @@ class DATA_OT_rigify_bone_group_add_theme(bpy.types.Operator):
@classmethod
def poll(cls, context):
return context.object.type == 'ARMATURE'
return context.object and context.object.type == 'ARMATURE'
def execute(self, context):
obj = context.object
......@@ -460,7 +464,7 @@ class DATA_OT_rigify_bone_group_remove(bpy.types.Operator):
@classmethod
def poll(cls, context):
return context.object.type == 'ARMATURE'
return context.object and context.object.type == 'ARMATURE'
def execute(self, context):
obj = context.object
......@@ -482,7 +486,7 @@ class DATA_OT_rigify_bone_group_remove_all(bpy.types.Operator):
@classmethod
def poll(cls, context):
return context.object.type == 'ARMATURE'
return context.object and context.object.type == 'ARMATURE'
def execute(self, context):
obj = context.object
......@@ -533,6 +537,8 @@ class DATA_PT_rigify_bone_groups(bpy.types.Panel):
@classmethod
def poll(cls, context):
if not context.object:
return False
return context.object.type == 'ARMATURE' and context.active_object.data.get("rig_id") is None
def draw(self, context):
......@@ -575,7 +581,8 @@ class BONE_PT_rigify_buttons(bpy.types.Panel):
@classmethod
def poll(cls, context):
if not context.object:
return False
return context.object.type == 'ARMATURE' and context.active_pose_bone\
and context.active_object.data.get("rig_id") is None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment