safe guard downloading of image for ayon_url

This commit is contained in:
Jakub Trllo 2025-11-19 11:11:50 +01:00
parent b684ba5ef0
commit 2af5e918a7

View file

@ -548,11 +548,17 @@ class _IconsCache:
elif icon_type == "ayon_url":
url = icon_def["url"].lstrip("/")
url = f"{ayon_api.get_base_url()}/{url}"
stream = io.BytesIO()
ayon_api.download_file_to_stream(url, stream)
pix = QtGui.QPixmap()
pix.loadFromData(stream.getvalue())
icon = QtGui.QIcon(pix)
try:
stream = io.BytesIO()
ayon_api.download_file_to_stream(url, stream)
pix = QtGui.QPixmap()
pix.loadFromData(stream.getvalue())
icon = QtGui.QIcon(pix)
except Exception:
log.warning(
"Failed to download image '%s'", url, exc_info=True
)
icon = None
elif icon_type == "transparent":
size = icon_def.get("size")