Fix T63504: Python Template 'ui_previews_dynamic_enum' error
authorPhilipp Oeser <info@graphics-engineer.com>
Fri, 12 Apr 2019 12:00:57 +0000 (14:00 +0200)
committerPhilipp Oeser <info@graphics-engineer.com>
Fri, 12 Apr 2019 12:10:10 +0000 (14:10 +0200)
thx @nacioss for the fix

release/scripts/templates_py/ui_previews_dynamic_enum.py

index 39a3750..37ee28b 100644 (file)
@@ -51,7 +51,11 @@ def enum_previews_from_directory_items(self, context):
         for i, name in enumerate(image_paths):
             # generates a thumbnail preview for a file.
             filepath = os.path.join(directory, name)
-            thumb = pcoll.load(filepath, filepath, 'IMAGE')
+            icon = pcoll.get(name)
+            if not icon:
+                thumb = pcoll.load(name, filepath, 'IMAGE')
+            else:
+                thumb = pcoll[name]
             enum_items.append((name, name, "", thumb.icon_id, i))
 
     pcoll.my_previews = enum_items