Skip to content

Commit

Permalink
don't bother trying to load svg with pillow
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Nov 22, 2024
1 parent ef01692 commit 819e1a0
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions xpra/client/gtk3/menu_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def get_appimage(app_name, icondata=b"", menu_icon_size=24) -> Gtk.Image | None:
if os.path.exists(icon_filename):
pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename=icon_filename)

def err(e):
def err(e) -> None:
log("failed to load icon", exc_info=True)
log.error("Error: failed to load icon data for '%s':", bytestostr(app_name))
log.estr(e)
Expand All @@ -133,13 +133,14 @@ def err(e):
if not pixbuf and icondata:
# let's try pillow:
try:
from xpra.codecs.pillow.decoder import open_only # pylint: disable=import-outside-toplevel
img = open_only(icondata)
has_alpha = img.mode == "RGBA"
width, height = img.size
rowstride = width * (3 + int(has_alpha))
pixbuf = get_pixbuf_from_data(img.tobytes(), has_alpha, width, height, rowstride)
return scaled_image(pixbuf, icon_size=menu_icon_size)
from xpra.codecs.pillow.decoder import open_only, is_svg # pylint: disable=import-outside-toplevel
if not is_svg(icondata):
img = open_only(icondata)
has_alpha = img.mode == "RGBA"
width, height = img.size
rowstride = width * (3 + int(has_alpha))
pixbuf = get_pixbuf_from_data(img.tobytes(), has_alpha, width, height, rowstride)
return scaled_image(pixbuf, icon_size=menu_icon_size)
except Exception as e:
err(e)
if pixbuf:
Expand Down

0 comments on commit 819e1a0

Please sign in to comment.