[Bf-blender-cvs] [a7dc6647aed] master: Fix T80697: children_recursive returns edit-bones from non edit-bone

Campbell Barton noreply at git.blender.org
Sat Sep 12 03:47:36 CEST 2020


Commit: a7dc6647aedfdd0450bca3c054f0b55036af00b7
Author: Campbell Barton
Date:   Sat Sep 12 11:41:21 2020 +1000
Branches: master
https://developer.blender.org/rBa7dc6647aedfdd0450bca3c054f0b55036af00b7

Fix T80697: children_recursive returns edit-bones from non edit-bone

Bone.children_recursive would return edit-bones when in edit-mode
irrespective of the type of the bone.

Check the type of self instead of the existence of edit-bones.

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

M	release/scripts/modules/bpy_types.py

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

diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index bf14d34ed20..1c31eaa39d0 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -352,16 +352,15 @@ class _GenericBone:
     @property
     def _other_bones(self):
         id_data = self.id_data
-        id_data_type = type(id_data)
 
-        if id_data_type == bpy_types.Object:
-            bones = id_data.pose.bones
-        elif id_data_type == bpy_types.Armature:
-            bones = id_data.edit_bones
-            if not bones:  # not in edit mode
-                bones = id_data.bones
-
-        return bones
+        # `id_data` is an 'Object' for `PosePone`, otherwise it's an `Armature`.
+        if isinstance(self, PoseBone):
+            return id_data.pose.bones
+        if isinstance(self, EditBone):
+            return id_data.edit_bones
+        if isinstance(self, Bone):
+            return id_data.bones
+        raise RuntimeError("Invalid type %r" % self)
 
 
 class PoseBone(StructRNA, _GenericBone, metaclass=StructMetaPropGroup):



More information about the Bf-blender-cvs mailing list