Skip to content

applets/kicker: fix app icon loading logic to better handle relative paths

ba44b69a added logic to handle apps that use an absolute path in their .desktop file to define their icon, which works. However in the process it introduced a subtle bug: if the icon is not an absolute path and it's just a normal icon name, when QFileInfo::exists() checks for the existence of that string, it will treat it as a relative file path and therefore look for it in the current working directory, which is typically the user's homedir. If it finds something, it will go down the wrong code path and end up returning a blank QIcon. This can be verified by adding a folder with the name of an app icon into ~ and restarting plasmashell; that app in Kickoff will have a blank icon.

To fix this, the icon loading code now first checks whether the icon returned by m_service->icon() is actually an absolute path. If not, it skips the logic to look for it on disk and goes straight to the codepath that looks for an icon with that name in the icon theme.

To minimize disk reads, it checks for absolute-file-path-ness by inspecting the string returned by m_service->icon() rather than using QFileInfo::isAbsolute(), because this is a hot code path and most icons will not have relative paths, so checking the disk for every one of them would be a waste of resources.

BUG: 457965 FIXED-IN: 5.24.7

@alex @davidedmundson @ratijas

Merge request reports

Loading