From 2504c5ac53116bdf15050926e347b0eb5481d26b Mon Sep 17 00:00:00 2001 From: Clement Ducarteron Date: Thu, 23 Mar 2023 17:34:59 +0100 Subject: [PATCH] Fix Issue when reloading Assets multiple times Crash because of previews already loaded --- operators/operators.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/operators/operators.py b/operators/operators.py index 525b4c1..949da7c 100644 --- a/operators/operators.py +++ b/operators/operators.py @@ -294,8 +294,9 @@ class VSETB_OT_load_assets(Operator): asset.preview = preview_id preview_path = Path(PREVIEWS_DIR / project.id / preview_id).with_suffix('.png') tracker.download_preview(preview_id, preview_path) - - ASSET_PREVIEWS.load(preview_id, preview_path.as_posix(), 'IMAGE') + + if preview_id not in ASSET_PREVIEWS: + ASSET_PREVIEWS.load(preview_id, preview_path.as_posix(), 'IMAGE', True) self.report({'INFO'}, f'Assets for {project.name} successfully loaded') @@ -330,6 +331,12 @@ class VSETB_OT_load_projects(Operator): episode.name = episode_data['name'] episode.id = episode_data['id'] + for metadata_data in tracker.get_shots_metadata(project_data): + metadata_type = project.metadata_types.add() + metadata_type.name = metadata_data + + # settings.load_metadata_types() + return {'FINISHED'}