From: joncruz Date: Mon, 30 Mar 2009 09:36:22 +0000 (+0000) Subject: Fix icon cache code to properly render multiple sizes as needed. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5b0687f31cd18c6516d5056eddba9b4ff552c539;p=inkscape.git Fix icon cache code to properly render multiple sizes as needed. --- diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 0bed152f8..220ffc722 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -908,6 +908,9 @@ static void addToIconSet(GdkPixbuf* pb, gchar const* name, GtkIconSize lsize, un for ( std::vector::iterator it = iconSetCache[name].begin(); it != iconSetCache[name].end(); ++it ) { if ( it->_lsize == lsize ) { + if (dump) { + g_message(" erasing %s:%d %p", name, it->_lsize, it->_pb); + } iconSetCache[name].erase(it); break; } @@ -937,9 +940,23 @@ bool prerender_icon(gchar const *name, GtkIconSize lsize, unsigned psize) if (pb) { return false; } else { - pb = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), name, psize, - (GtkIconLookupFlags) 0, NULL); + GtkIconTheme* theme = gtk_icon_theme_get_default(); + if ( gtk_icon_theme_has_icon(theme, name) ) { + gint *sizeArray = gtk_icon_theme_get_icon_sizes( theme, name ); + for (gint* cur = sizeArray; *cur; cur++) { + if (static_cast(psize) == *cur) { + pb = gtk_icon_theme_load_icon( theme, name, psize, + (GtkIconLookupFlags) 0, NULL ); + break; + } + } + g_free(sizeArray); + sizeArray = 0; + } if (!pb) { + if (dump) { + g_message("prerender_icon [%s] %d", name, psize); + } guchar* px = load_svg_pixels(name, lsize, psize); if ( !px ) { // check for a fallback name @@ -958,6 +975,9 @@ bool prerender_icon(gchar const *name, GtkIconSize lsize, unsigned psize) g_message("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX error!!! pixels not found for '%s'", name); } } + else if (dump) { + g_message("prerender_icon [%s] %d NOT!!!!!!", name, psize); + } if (pb) { pb_cache[key] = pb;