diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-09-12 04:41:21 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-09-12 04:45:33 +0300 |
commit | a7dc6647aedfdd0450bca3c054f0b55036af00b7 (patch) | |
tree | 176c2056feac280ef564b6ae4f9f8b4033f8eade | |
parent | b00820c04d2f06bd483b41d07d195b3bfc2f60ba (diff) |
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.
-rw-r--r-- | release/scripts/modules/bpy_types.py | 17 |
1 files changed, 8 insertions, 9 deletions
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): |