[preview] Better handle exceptions when loading images

This commit is contained in:
lovetox
2020-04-21 18:05:26 +02:00
parent caff6031d7
commit 0c8d3c8827
2 changed files with 16 additions and 3 deletions

View File

@@ -216,6 +216,7 @@ def pixbuf_from_data(data):
loader = GdkPixbuf.PixbufLoader()
try:
loader.write(data)
loader.close()
except GLib.Error:
# Fallback to Pillow
input_file = BytesIO(data)
@@ -233,7 +234,6 @@ def pixbuf_from_data(data):
input_file.close()
return pixbuf
loader.close()
return loader.get_pixbuf()