From 19f2bcf286a6c5541b5061212488648b3953b49d Mon Sep 17 00:00:00 2001 From: Alexander Shaduri Date: Thu, 5 Oct 2017 20:14:23 +0000 Subject: [PATCH] Fixed a crash when icon theme doesn't contain a specified icon. --- gsmartcontrol/src/gsc_main_window_iconview.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/gsmartcontrol/src/gsc_main_window_iconview.h b/gsmartcontrol/src/gsc_main_window_iconview.h index f048e5d..fad1a0e 100644 --- a/gsmartcontrol/src/gsc_main_window_iconview.h +++ b/gsmartcontrol/src/gsc_main_window_iconview.h @@ -87,10 +87,15 @@ class GscMainWindowIconView : public Gtk::IconView { } // Try XDG version first - hd_icon = default_icon_theme->load_icon("drive-harddisk", 64, get_scale_factor(), Gtk::IconLookupFlags(0)); + try { + hd_icon = default_icon_theme->load_icon("drive-harddisk", 64, get_scale_factor(), Gtk::IconLookupFlags(0)); + } catch (...) { } // ignore exceptions + if (!hd_icon) { // Before gtk 3.10 it was called gtk-harddisk. - hd_icon = default_icon_theme->load_icon("gtk-harddisk", 64, get_scale_factor(), Gtk::IconLookupFlags(0)); + try { + hd_icon = default_icon_theme->load_icon("gtk-harddisk", 64, get_scale_factor(), Gtk::IconLookupFlags(0)); + } catch (...) { } // ignore exceptions } if (!hd_icon) { // Still no luck, use bundled ones. @@ -103,10 +108,15 @@ class GscMainWindowIconView : public Gtk::IconView { } // Try XDG version first - cddvd_icon = default_icon_theme->load_icon("media-optical", 64, get_scale_factor(), Gtk::IconLookupFlags(0)); + try { + cddvd_icon = default_icon_theme->load_icon("media-optical", 64, get_scale_factor(), Gtk::IconLookupFlags(0)); + } catch (...) { } // ignore exceptions + if (!cddvd_icon) { // Before gtk 3.10 it was called gtk-cdrom. - cddvd_icon = default_icon_theme->load_icon("gtk-cdrom", 64, get_scale_factor(), Gtk::IconLookupFlags(0)); + try { + cddvd_icon = default_icon_theme->load_icon("gtk-cdrom", 64, get_scale_factor(), Gtk::IconLookupFlags(0)); + } catch (...) { } // ignore exceptions } if (!cddvd_icon) { // Still no luck, use bundled ones.