Skip to content

Commit

Permalink
handle missing PIL more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Apr 29, 2024
1 parent e914616 commit c580f1b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions xpra/client/gl/backing.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,8 @@ def refresh_screen(context) -> None:

def validate_cursor(self) -> bool:
cursor_data = self.cursor_data
if not cursor_data or len(cursor_data)<9:
return False
cw = int(cursor_data[3])
ch = int(cursor_data[4])
pixels = cursor_data[8]
Expand Down Expand Up @@ -960,6 +962,9 @@ def get_default_cursor_data(self) -> tuple:
if os.path.exists(filename):
try:
from PIL import Image
except ImportError:
return ()
try:
img = Image.open(filename)
log(f"get_default_cursor_data() Image({filename=})={img}")
w, h = img.size
Expand All @@ -969,9 +974,9 @@ def get_default_cursor_data(self) -> tuple:
if img.mode != "RGBA":
img = img.convert("RGBA")
pixels = img.tobytes("raw", "BGRA")
except Exception:
except Exception as e:
log(f"Image.open({filename})", exc_info=True)
log.warn(f"Warning: failed to load {filename!r}")
log.warn(f"Warning: failed to load {filename!r}: {e}")
return "raw", x, y, w, h, xhot, yhot, serial, pixels, name

def set_cursor_data(self, cursor_data) -> None:
Expand Down

0 comments on commit c580f1b

Please sign in to comment.