Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pose_library/operators.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/pose_library/operators.py b/pose_library/operators.py
index 008aceda..c0c8b332 100644
--- a/pose_library/operators.py
+++ b/pose_library/operators.py
@@ -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: