nemo-file: fall back to custom-icon-name when the custom-icon path no longer exists - #3809
Closed
nynjapirate wants to merge 1 commit into
Closed
Conversation
… gone get_custom_icon() prefers the custom-icon metadata (a path) over the custom-icon-name metadata, which is fine -- except that g_file_icon_new() returns a valid GIcon even when the file it points at does not exist. The resulting GFileIcon is non-NULL, so the custom-icon-name branch is never reached, and the file ends up with no custom icon at all: the stale path silently masks a perfectly good icon name. In practice this means that moving or renaming an icon file (for example reorganising an icon theme) silently blanks the custom icon of every file and folder that referenced it, with no error and no fallback, even for items that also have a valid custom-icon-name stored. Skip a custom-icon path that no longer resolves, so the icon name is used instead. Existence is only checked for native files, to avoid introducing blocking I/O for remote locations.
Member
|
Hi, unfortunately this won't work -
Also, you wouldn't ordinarily have both a path and an icon-name set. Using nemo's file properties window clears whichever path you didn't use, so you'd never have both to choose from. It looks like our 'folder-color' extension may potentially allow both values to be set, but that should be fixed there. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A custom icon set by path silently wins over a valid custom icon name, even when the path points at a file that no longer exists — so the item ends up with no custom icon at all, with no error and no fallback.
Cause
In
get_custom_icon()(libnemo-private/nemo-file.c):g_file_icon_new()does not touch the filesystem, so it happily returns a validGFileIconfor a path that no longer resolves. ThatGIconis non-NULL, so thecustom-icon-namebranch below is never taken. TheGFileIconthen fails to load at draw time and the item simply shows no custom icon.Preferring the path over the name is intentional and unchanged here — the bug is that a dead path still wins.
Impact
Reorganising an icon collection (moving/renaming the image files) silently blanks the custom icon of every file and folder that referenced them. There is no error, no warning, and no fallback — including for items that also have a perfectly good
custom-icon-namestored, which is simply never consulted.I hit this with 26 folders whose icons went blank after the icon files were moved. Several of them had a valid
custom-icon-namein their metadata the entire time; it was never used.Fix
Skip a
custom-iconpath that no longer resolves, so the existingcustom-icon-namefallback is reached. Existence is checked for native files only, so no blocking I/O is introduced for remote locations.Reproducing
custom-icon-nameis ignored.folder-music.Verified against the two code paths with identical metadata: the old logic builds a
GFileIconthat renders nothing; the new logic skips the dead path and resolves the themed icon.