From 6d9db23342510ea7255face6e72ee0a28ae24a30 Mon Sep 17 00:00:00 2001 From: HenryOfCarim Date: Tue, 20 Aug 2024 03:10:49 +0300 Subject: [PATCH] Fix for Pack operator's poll erro (#119) There was an error visible in console, when user removed export node, looks like it tried to poll the last item in the list that didn't exist anymore --- albam/blender_ui/export_panel.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/albam/blender_ui/export_panel.py b/albam/blender_ui/export_panel.py index 52be7d4..0d6f53a 100644 --- a/albam/blender_ui/export_panel.py +++ b/albam/blender_ui/export_panel.py @@ -275,12 +275,19 @@ def _execute(self, context): # pragma: no cover def poll(cls, context): vfs_e = context.scene.albam.exported vfs_i = context.scene.albam.vfs + # TODO: simplify this mess if len(vfs_e.file_list) == 0 or len(vfs_i.file_list) == 0: return False index_e = vfs_e.file_list_selected_index index_i = vfs_i.file_list_selected_index - exported_item = vfs_e.file_list[index_e] - imported_item = vfs_i.file_list[index_i] + if index_e < (len(vfs_e.file_list)): + exported_item = vfs_e.file_list[index_e] + else: + return False + if index_i < (len(vfs_i.file_list)): + imported_item = vfs_i.file_list[index_i] + else: + return False if not exported_item or not imported_item: return False return imported_item.is_archive and exported_item.is_root