[Sugar-devel] [PATCH toolkit-gtk3] IconEntry, set_icon_from_name: handle case when icon can not be found cleanly

Manuel Quiñones manuq at laptop.org
Mon Sep 17 09:42:21 EDT 2012


2012/9/17 Simon Schampijer <simon at schampijer.de>:
> From: Simon Schampijer <simon at laptop.org>
>
> Sugar crashes if the sugar theme has not been set (in sugar-session)
> in the set_icon_from_name method since some if the requested icons
> can not be found. Handle that case cleanly.

Good catch Simon, yes let's handle this well.  Please push.

>
> Signed-off-by: Simon Schampijer <simon at laptop.org>
> ---
>  src/sugar3/graphics/iconentry.py | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/src/sugar3/graphics/iconentry.py b/src/sugar3/graphics/iconentry.py
> index 154dfd0..f64fa5f 100644
> --- a/src/sugar3/graphics/iconentry.py
> +++ b/src/sugar3/graphics/iconentry.py
> @@ -15,6 +15,8 @@
>  # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
>  # Boston, MA 02111-1307, USA.
>
> +import logging
> +
>  from gi.repository import GObject
>  from gi.repository import Gtk
>  from gi.repository import Gdk
> @@ -42,6 +44,10 @@ class IconEntry(Gtk.Entry):
>          icon_info = icon_theme.lookup_icon(name,
>                                             Gtk.IconSize.SMALL_TOOLBAR,
>                                             0)
> +        if not icon_info:
> +            logging.warning('IconEntry set_icon_from_name: icon %s not '
> +                            'found in the theme.', name)
> +            return
>
>          if icon_info.get_filename().endswith('.svg'):
>              loader = _SVGLoader()
> --
> 1.7.11.4
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel



-- 
.. manuq ..


More information about the Sugar-devel mailing list