Skip to content
Snippets Groups Projects
Commit 335b4d7c authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Pose Library: change how cleanup is done after Copy As Asset

Copy As Asset creates an asset datablock, saves it to disk, and then
removes it again. This removal has a check to ensure the temp datablock
isn't accidentally still in use by something. When this check fails, it now
still forces the cleanup. The message is now there just to ask people to
file a bug report, instead of blocking their workflow altogether.
parent 6cd3a735
No related branches found
No related tags found
No related merge requests found
......@@ -216,22 +216,25 @@ class POSELIB_OT_copy_as_asset(PoseAssetCreator, Operator):
filepath = self.save_datablock(asset)
# The asset has been saved to disk, so to clean up it has to loose its asset & fake user status.
asset.asset_clear()
asset.use_fake_user = False
if asset.users > 0:
self.report({"ERROR"}, "Unexpected non-null user count for the asset")
return {"FINISHED"}
bpy.data.actions.remove(asset)
context.window_manager.clipboard = "%s%s" % (
self.CLIPBOARD_ASSET_MARKER,
filepath,
)
asset_browser.tag_redraw(context.screen)
self.report({"INFO"}, "Pose Asset copied, use Paste As New Asset in any Asset Browser to paste")
# The asset has been saved to disk, so to clean up it has to loose its asset & fake user status.
asset.asset_clear()
asset.use_fake_user = False
# The asset can be removed from the main DB, as it was purely created to
# be stored to disk, and not to be used in this file.
if asset.users > 0:
# This should never happen, and indicates a bug in the code. Having a warning about it is nice,
# but it shouldn't stand in the way of actually cleaning up the meant-to-be-temporary datablock.
self.report({"WARNING"}, "Unexpected non-zero user count for the asset, please report this as a bug")
bpy.data.actions.remove(asset)
return {"FINISHED"}
def save_datablock(self, action: Action) -> Path:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment