st/icon: Check icon name for empty string in setter function

Don't try to create a GIcon if the given icon name is empty, it will
lead to failure when loading the icon anyway, instead set the gicon to
NULL just as we do in the `set_gicon()` API when unsetting an icon.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/888
This commit is contained in:
Jonas Dreßler 2019-11-21 19:05:11 +07:00 committed by Florian Müllner
parent 69a5e89096
commit 8b15519160

View File

@ -553,7 +553,7 @@ st_icon_set_icon_name (StIcon *icon,
g_return_if_fail (ST_IS_ICON (icon));
if (icon_name)
if (icon_name && *icon_name)
gicon = g_themed_icon_new_with_default_fallbacks (icon_name);
g_object_freeze_notify (G_OBJECT (icon));
@ -730,7 +730,7 @@ st_icon_set_fallback_icon_name (StIcon *icon,
g_return_if_fail (ST_IS_ICON (icon));
if (fallback_icon_name != NULL)
if (fallback_icon_name && *fallback_icon_name)
gicon = g_themed_icon_new_with_default_fallbacks (fallback_icon_name);
g_object_freeze_notify (G_OBJECT (icon));