From a7dc6647aedfdd0450bca3c054f0b55036af00b7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 12 Sep 2020 11:41:21 +1000 Subject: 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. --- release/scripts/modules/bpy_types.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to '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): -- cgit v1.2.3