Skip to content

Commit feef5d9

Browse files
committed
deployDesktopFileAndIcon(): ignore case in file extensions
1 parent f49d663 commit feef5d9

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/core/appdir_root_setup.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,22 @@ namespace linuxdeploy {
121121

122122
// From here, the code comparing the current icon and the so far best icon begins
123123

124+
const auto currentExtension = util::strLower(iconPath.extension().string());
125+
const auto bestIconExtension = util::strLower(bestIcon->extension().string());
124126
// SVGs are preferred, and (normally) only come in scalable/apps/; process them early
125-
if (iconPath.extension() == ".svg") {
127+
if (currentExtension == ".svg") {
126128
// There's only one spec-compliant place for an SVG icon (icons/scalable/apps); but if
127129
// a full filename is used in the desktop file (Icon=a.svg) then two SVG icons can
128130
// match it: scalable/apps/a.svg and scalable/apps/a.svg.svg; in this case a.svg wins
129-
if (matchesFilenameWithExtension || bestIcon->extension() != ".svg")
131+
if (matchesFilenameWithExtension || bestIconExtension != ".svg")
130132
bestIcon = &iconPath;
131133

132134
break; // Further icons can't be better than what bestIcon has now.
133135
}
134136

135137
// As of here, the _current_ icon is a raster one (PNG or XPM)
136138

137-
if (bestIcon->extension() == ".svg" // SVG is always better
139+
if (bestIconExtension == ".svg" // SVG is always better
138140
|| (!matchesFilenameWithExtension && bestIcon->filename() == iconName)) // Better filename match
139141
continue;
140142

@@ -150,11 +152,13 @@ namespace linuxdeploy {
150152
// The code diverts from Icon Naming Spec here, since the spec relies on reading
151153
// index.theme data and taking Threshold and MinSize/MaxSize values from there. Instead,
152154
// merely figure which size is "logarithmically further" from the sweet spot of 64,
153-
// preferring larger icons in case of a tie (see getIconPreference() implementation).
155+
// preferring larger icons in case of a tie (see getIconPreference() implementation);
156+
// as a last resort, if the preference is the same (e.g. two icons deployed to pixmaps/),
157+
// PNGs win over XPMs.
154158
const auto currentPreference = getIconPreference(iconPath);
155159
const auto bestPreference = getIconPreference(*bestIcon);
156160
if (currentPreference > bestPreference
157-
|| (currentPreference == bestPreference && iconPath.extension() < bestIcon->extension()))
161+
|| (currentPreference == bestPreference && currentExtension < bestIconExtension))
158162
bestIcon = &iconPath;
159163
}
160164

0 commit comments

Comments
 (0)