Fix #122838: Save and Removal of Themes with Multi-Word Names

In Preferences / Themes you can add a new theme with a name that has
multiple words and the resulting file name will have spaces converted
to underscores. Unfortunately such multi-word themes will not pass the
poll function for saving and deletion. This PR just adds calls that
convert from the display name to file name in order for these to work.

Pull Request: https://projects.blender.org/blender/blender/pulls/122848
This commit is contained in:
Harley Acheson
2024-06-07 20:20:06 +02:00
committed by Harley Acheson
parent 35cfc71b95
commit d08cebf6d7

View File

@@ -600,6 +600,7 @@ class RemovePresetInterfaceTheme(AddPresetBase, Operator):
from bpy.utils import is_path_builtin
preset_menu_class = getattr(bpy.types, cls.preset_menu)
name = preset_menu_class.bl_label
name = bpy.path.clean_name(name)
filepath = bpy.utils.preset_find(name, cls.preset_subdir, ext=".xml")
if not bool(filepath) or is_path_builtin(filepath):
cls.poll_message_set("Built-in themes cannot be removed")
@@ -633,6 +634,7 @@ class SavePresetInterfaceTheme(AddPresetBase, Operator):
preset_menu_class = getattr(bpy.types, cls.preset_menu)
name = preset_menu_class.bl_label
name = bpy.path.clean_name(name)
filepath = bpy.utils.preset_find(name, cls.preset_subdir, ext=".xml")
if (not filepath) or is_path_builtin(filepath):
cls.poll_message_set("Built-in themes cannot be overwritten")
@@ -644,6 +646,7 @@ class SavePresetInterfaceTheme(AddPresetBase, Operator):
import rna_xml
preset_menu_class = getattr(bpy.types, self.preset_menu)
name = preset_menu_class.bl_label
name = bpy.path.clean_name(name)
filepath = bpy.utils.preset_find(name, self.preset_subdir, ext=".xml")
if not bool(filepath) or is_path_builtin(filepath):
self.report({'ERROR'}, "Built-in themes cannot be overwritten")