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:
authorSybren A. Stüvel <sybren@stuvel.eu>2021-08-11 12:22:43 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2021-08-11 12:22:43 +0300
commit335b4d7c8cfe978efba2d2d0fc3be20a2c69d93b (patch)
tree1023014585dd5f0a93bd0e46ab0f4497e43fb323
parent6cd3a73571342ad517a9f2e8b44153aa3bab00c9 (diff)
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.
-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: