[Bf-extensions-cvs] [92cfcccf] blender-v2.83-release: Rigify: avoid AttributeErrors when there is no active object

Sybren A. Stüvel noreply at git.blender.org
Fri May 22 16:05:58 CEST 2020


Commit: 92cfcccf0cd393c450a15ad8b0ff5cc6b0bb693d
Author: Sybren A. Stüvel
Date:   Fri May 22 16:05:34 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rBA92cfcccf0cd393c450a15ad8b0ff5cc6b0bb693d

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.

===================================================================

M	rigify/ui.py

===================================================================

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



More information about the Bf-extensions-cvs mailing list