fix(linux): Handle corrupt icon file

Fixes #5584.
This commit is contained in:
Eberhard Beilharz 2021-08-16 15:53:05 +02:00
parent 4eac85907f
commit c8049a0cd2
No known key found for this signature in database
GPG key ID: 64A39A9E98B53105

View file

@ -23,6 +23,7 @@ from keyman_config.install_window import InstallKmpWindow, find_keyman_image
from keyman_config.uninstall_kmp import uninstall_kmp
from keyman_config.accelerators import bind_accelerator, init_accel
from keyman_config.get_kmp import InstallLocation, get_keyboard_dir, get_keyman_dir
from gi.overrides.GLib import GError
class ViewInstalledWindowBase(Gtk.Window):
@ -224,19 +225,26 @@ class ViewInstalledWindow(ViewInstalledWindowBase):
welcome_file = os.path.join(path, "welcome.htm")
options_file = os.path.join(path, "options.htm")
icofile = os.path.join(path, kmpdata['packageID'] + bmppng)
icofile_name = os.path.join(path, kmpdata['packageID'] + bmppng)
if not os.path.isfile(welcome_file):
welcome_file = None
if not os.path.isfile(options_file):
options_file = None
if not os.path.isfile(icofile):
icofile = os.path.join(path, kmpdata['keyboardID'] + bmppng)
if not os.path.isfile(icofile):
icofile = find_keyman_image("icon_kmp.png")
if not os.path.isfile(icofile_name):
icofile_name = os.path.join(path, kmpdata['keyboardID'] + bmppng)
if not os.path.isfile(icofile_name):
icofile_name = find_keyman_image("icon_kmp.png")
try:
icofile = GdkPixbuf.Pixbuf.new_from_file_at_size(icofile_name, 16, 16)
except GError:
_, value, _ = sys.exc_info()
logging.info("Error reading icon file %s: %s" % (icofile_name, value.message))
icofile = None
store.append([
GdkPixbuf.Pixbuf.new_from_file_at_size(icofile, 16, 16),
icofile,
kmpdata['name'],
kmpdata['version'],
kmpdata['packageID'],