From 39b130bc6606763da7490e14ab8556306f822a91 Mon Sep 17 00:00:00 2001 From: Damien Picard Date: Fri, 3 Mar 2023 15:04:20 +0100 Subject: [PATCH] Pose library: fix asset creation operator poll when no object active When the POSELIB_OT_create_pose_asset operator was displayed in the UI, for instance pressing F3 after deleting an object, the poll method tried to access the mode of a None object, leading to the following error message being displayed: ``` Traceback (most recent call last): File ".../3.5/scripts/addons/pose_library/operators.py", line 63, in poll if context.object.mode != "POSE": AttributeError: 'NoneType' object has no attribute 'mode' ``` This commit adds a check for whether an object is currently active. --- pose_library/operators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pose_library/operators.py b/pose_library/operators.py index 28188f03a..c87c74db1 100644 --- a/pose_library/operators.py +++ b/pose_library/operators.py @@ -60,9 +60,9 @@ class POSELIB_OT_create_pose_asset(PoseAssetCreator, Operator): @classmethod def poll(cls, context: Context) -> bool: - if context.object.mode != "POSE": + if context.object is None or context.object.mode != "POSE": # The operator assumes pose mode, so that bone selection is visible. - cls.poll_message_set("The object must be in Pose mode") + cls.poll_message_set("An active armature object in pose mode is needed") return False # Make sure that if there is an asset browser open, the artist can see the newly created pose asset. -- 2.30.2