From 9a0711eac216c60c4b7ea91843a8c0f009cc5fa2 Mon Sep 17 00:00:00 2001 From: Jonathon Jongsma Date: Sat, 14 Oct 2006 16:39:25 -0500 Subject: [PATCH] Fix for stale gtk icon cache issue that would crash the program. Thanks to Varun Hiremath The essence of the issue was that if a user first installs the program in /usr/local (the default) and then uninstalls it and installs it to /usr, the icon cache in /usr/local will never be updated so it will still think that there are agave icons under the /usr/local prefix. Since /usr/local is before /usr in the icon theme search path, it will then try to load the icon from /usr/local, and since the file no longer exists, the program will crash. I added a uninstall-hook to the makefile to update the icon cache when the program is uninstalled, and in addition, I now catch the exception that is thrown in the AboutWindow constructor just in case the file is not found. Now the program will not crash, it will just show an 'About' dialog without an image. --- pixmaps/Makefile.am | 5 ++++- src/dialogs/gcs-about-window.cc | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/pixmaps/Makefile.am b/pixmaps/Makefile.am index f41911f..c859f22 100644 --- a/pixmaps/Makefile.am +++ b/pixmaps/Makefile.am @@ -6,7 +6,10 @@ dist_svgicon_DATA = agave-icon.svg gtk_update_icon_cache = gtk-update-icon-cache -f -t ${themedir} -install-data-hook: +install-data-hook: update-icon-cache +uninstall-hook: update-icon-cache + +update-icon-cache: @-if test -z "$(DESTDIR)"; then \ echo "Updating Gtk icon cache."; \ $(gtk_update_icon_cache); \ diff --git a/src/dialogs/gcs-about-window.cc b/src/dialogs/gcs-about-window.cc index a15203b..a7a96b5 100644 --- a/src/dialogs/gcs-about-window.cc +++ b/src/dialogs/gcs-about-window.cc @@ -32,6 +32,7 @@ #endif // HAVE_GNOME #include +#include "core/log-stream.h" #include "gcs-about-window.h" #include "gcs-i18n.h" @@ -87,14 +88,22 @@ #endif // HAVE_GNOME Glib::ustring translation_credits = _("translator-credits"); set_translator_credits(translation_credits); - Glib::RefPtr theme = Gtk::IconTheme::get_default(); const Glib::ustring icon_name = "agave-icon"; - // FIXME: Unix path separators + Glib::RefPtr theme = Gtk::IconTheme::get_default(); + if (theme->has_icon(icon_name)) { - m_logo = theme->load_icon(icon_name, m_logoSize, - Gtk::ICON_LOOKUP_USE_BUILTIN); - set_logo(m_logo); + try + { + m_logo = theme->load_icon(icon_name, m_logoSize, + Gtk::ICON_LOOKUP_USE_BUILTIN); + set_logo(m_logo); + } + catch (const Glib::Error& e) + { + Glib::ustring message = "Couldn't load Agave logo image from theme. " + e.what(); + g_warning(message.c_str()); + } } } -- 1.4.2.gd4ba-dirty