From bafddfd9fbe3af94036f28bc7eb956c41f76c608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 23 Sep 2025 17:09:03 +0200 Subject: [PATCH] Refactor: convert "Clear Useless Actions" operator to current Action API Convert the code for the "Clear Useless Actions" operator from the legacy Actions API to the current API. No functional changes. This is part of #146586 Pull Request: https://projects.blender.org/blender/blender/pulls/147060 --- scripts/startup/bl_operators/anim.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/startup/bl_operators/anim.py b/scripts/startup/bl_operators/anim.py index c21199b99ff..f102e243f49 100644 --- a/scripts/startup/bl_operators/anim.py +++ b/scripts/startup/bl_operators/anim.py @@ -352,6 +352,16 @@ class ClearUselessActions(Operator): def poll(cls, _context): return bool(bpy.data.actions) + @staticmethod + def has_fcurves(action: bpy.types.Action) -> bool: + for layer in action.layers: + for strip in layer.strips: + assert strip.type == 'KEYFRAME' + for channelbag in strip.channelbags: + if channelbag.fcurves: + return True + return False + def execute(self, _context): removed = 0 @@ -365,7 +375,7 @@ class ClearUselessActions(Operator): # if it has F-Curves, then it's a "action library" # (i.e. walk, wave, jump, etc.) # and should be left alone as that's what fake users are for! - if not action.fcurves: + if not self.has_fcurves(action): # mark action for deletion action.user_clear() removed += 1