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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user