Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2020-05-22 17:05:34 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2020-05-22 17:05:34 +0300
commit92cfcccf0cd393c450a15ad8b0ff5cc6b0bb693d (patch)
treee30ef4bdbdb34c0b7256381ce350bced26421e7b
parent9a9832d5d7fe61a446516f2e2722f8356bd7e709 (diff)
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.
-rw-r--r--rigify/ui.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/rigify/ui.py b/rigify/ui.py
index f8491d86..ad1c4156 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