Fix T76849: Duplicate templates show in the New menu
authorCampbell Barton <ideasman42@gmail.com>
Mon, 18 May 2020 07:59:52 +0000 (17:59 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 18 May 2020 07:59:52 +0000 (17:59 +1000)
release/scripts/startup/bl_ui/space_topbar.py

index 1e6f03c2b0c4b267a670c716b7b20b3875cc617f..9cc979f7546177036bd46a8fa03904effa585540 100644 (file)
@@ -316,16 +316,18 @@ class TOPBAR_MT_file_new(Menu):
 
         template_paths = bpy.utils.app_template_paths()
 
-        # expand template paths
-        app_templates = []
+        # Expand template paths.
+
+        # Use a set to avoid duplicate user/system templates.
+        # This is a corner case, but users managed to do it! T76849.
+        app_templates = set()
         for path in template_paths:
             for d in os.listdir(path):
                 if d.startswith(("__", ".")):
                     continue
                 template = os.path.join(path, d)
                 if os.path.isdir(template):
-                    # template_paths_expand.append(template)
-                    app_templates.append(d)
+                    app_templates.add(d)
 
         return sorted(app_templates)