Fix #115590: UV window menus disappearing

Due to lack of forward compatibility, tool_settings.snap_uv_element
could return empty if a 4.0 file is opened in 3.6.

This causes a Python error when trying to identify the element's icon.

Avoid this python error.

Pull Request: https://projects.blender.org/blender/blender/pulls/116944
This commit is contained in:
Germano Cavalcante 2023-12-13 13:53:36 -03:00 • committed by Gitea
parent a423a329e8
commit 56039bbc2a

View file

@ -751,7 +751,10 @@ class IMAGE_HT_header(Header):
# Snap.
snap_uv_element = tool_settings.snap_uv_element
act_snap_uv_element = tool_settings.bl_rna.properties["snap_uv_element"].enum_items[snap_uv_element]
try:
act_snap_icon = tool_settings.bl_rna.properties["snap_uv_element"].enum_items[snap_uv_element].icon
except KeyError:
act_snap_icon = 'NONE'
row = layout.row(align=True)
row.prop(tool_settings, "use_snap_uv", text="")
@ -759,7 +762,7 @@ class IMAGE_HT_header(Header):
sub = row.row(align=True)
sub.popover(
panel="IMAGE_PT_snapping",
icon=act_snap_uv_element.icon,
icon=act_snap_icon,
text="",
)