From 92cfcccf0cd393c450a15ad8b0ff5cc6b0bb693d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= <sybren@stuvel.eu> Date: Fri, 22 May 2020 16:05:34 +0200 Subject: [PATCH] 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. --- rigify/ui.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/rigify/ui.py b/rigify/ui.py index f8491d861..ad1c41564 100644 --- a/rigify/ui.py +++ b/rigify/ui.py @@ -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 -- GitLab