After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 692955 - [W32] GtkIconCache fails to load non-builtin icons
[W32] GtkIconCache fails to load non-builtin icons
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Win32
unspecified
Other Windows
: Normal normal
: ---
Assigned To: gtk-win32 maintainers
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2013-01-31 18:06 UTC by LRN
Modified: 2013-02-21 18:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
A hack to compare subdirectories dirsep-insensitively (1.25 KB, patch)
2013-01-31 18:09 UTC, LRN
needs-work Details | Review
Make sure icon cache has /-separated subdirs only (1.76 KB, patch)
2013-02-06 12:16 UTC, LRN
needs-work Details | Review
Make sure icon cache has /-separated subdirs only (v2 - use g_build_path) (2.22 KB, patch)
2013-02-21 18:27 UTC, LRN
committed Details | Review

Description LRN 2013-01-31 18:06:55 UTC
get_directory_index() does strcmp() on two relative directory names. One comes from a index.theme file and uses "/" directory separator for directory names, the other comes from icon-theme.cache file that is generated by gtk-update-icon-cache.
gtk-update-icon-cache writes directory names in the same form it gets them from GLib - namely, they will have "\" directory separator on W32.

As a result, get_directory_index() returns -1, and later GtkIconCache can't load any icon from files in share/icons/<themename>/<resolution>/<category>

Bug in get_directory_index() is present in both 2.x and 3.x branches; i'm not sure whether 3.x is affected - most likely it is. 2.x is affected for sure.
Comment 1 LRN 2013-01-31 18:09:20 UTC
Created attachment 234928 [details] [review]
A hack to compare subdirectories dirsep-insensitively

Since GLib has no usable-from-outside path normalization routines, and using create-GFile-then-get-its-filename-attribute approach would be an overkill, this hack just does a dumb string comparison, except that it allows mismatching directory separators to be used (everything else must match though - number of separators, character case, etc).
Comment 2 Alexander Larsson 2013-02-01 16:59:16 UTC
It seems wrong to do the extra work at runtime. We should normalize the strings we put into the cache file instead.
Comment 3 Matthias Clasen 2013-02-01 22:45:57 UTC
Review of attachment 234928 [details] [review]:

according to alex' comment
Comment 4 LRN 2013-02-06 12:16:48 UTC
Created attachment 235304 [details] [review]
Make sure icon cache has /-separated subdirs only

Alternative version - fixes gtk-update-icon-cache instead.

By the way, There's a pathnamecmp() function in gtk/gtkimmulticontext.c, and it does roughly the same that attachment #234928 [details] did, so maybe it isn't as bad as Alex thinks.
Comment 5 Alexander Larsson 2013-02-08 09:07:47 UTC
Review of attachment 235304 [details] [review]:

looks good to me
Comment 6 Alexander Larsson 2013-02-08 09:32:46 UTC
Review of attachment 235304 [details] [review]:

::: gtk/updateiconcache.c
@@ +626,2 @@
       path = g_build_filename (dir_path, name, NULL);
+      replace_backslashes_with_slashes (path);

Actually, you should probably only do this on the original base_path, and then use g_build_påth ("/", ... instead of g_build_filename (...
Comment 7 LRN 2013-02-08 13:23:05 UTC
Dunno, i don't understand the code well enough to change the functions around. Just added slash conversion.

If you think that switching filename-building functions is ok - well, do it then :)
Comment 8 Alexander Larsson 2013-02-08 15:35:04 UTC
Well, g_build_filename() is just a call to g_build_path() with the system specific separator. 

Its stupid to call that and then replace strings in the results rather than just adding the right type of  separators in the first place.
Comment 9 LRN 2013-02-21 18:27:14 UTC
Created attachment 237089 [details] [review]
Make sure icon cache has /-separated subdirs only (v2 - use g_build_path)

Also please backport it to 2.x branch (diff applies cleanly, except for the last part, where g_type_init() is still used).
Comment 10 Alexander Larsson 2013-02-21 18:36:44 UTC
Comment on attachment 237089 [details] [review]
Make sure icon cache has /-separated subdirs only (v2 - use g_build_path)

Attachment 237089 [details] pushed as 8e80fd1 - Make sure icon cache has /-separated subdirs only (v2 - use g_build_path)