do not hang on GLib error see: #14

This commit is contained in:
Martin Wagner 2020-11-13 19:06:01 +01:00
parent 13d7c2d36f
commit 52de223b0f

View File

@ -40,7 +40,7 @@ import dbus.service
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)
VERSION="0.9.6" # sync with setup.py
VERSION="0.9.6-dev" # sync with setup.py
COVER_REGEX=r"^\.?(album|cover|folder|front).*\.(gif|jpeg|jpg|png)$"
@ -1419,8 +1419,14 @@ class Cover(object):
def get_pixbuf(self, size):
if self.path is None: # fallback needed
self.path=Gtk.IconTheme.get_default().lookup_icon("media-optical", size, Gtk.IconLookupFlags.FORCE_SVG).get_filename()
return GdkPixbuf.Pixbuf.new_from_file_at_size(self.path, size, size)
path=Gtk.IconTheme.get_default().lookup_icon("media-optical", size, Gtk.IconLookupFlags.FORCE_SVG).get_filename()
return GdkPixbuf.Pixbuf.new_from_file_at_size(path, size, size)
else:
try:
return GdkPixbuf.Pixbuf.new_from_file_at_size(self.path, size, size)
except: # load fallback if cover can't be loaded (GLib: Couldnt recognize the image file format for file...)
path=Gtk.IconTheme.get_default().lookup_icon("media-optical", size, Gtk.IconLookupFlags.FORCE_SVG).get_filename()
return GdkPixbuf.Pixbuf.new_from_file_at_size(path, size, size)
###########
# browser #