Bug 429530 - KIO::iconNameForUrl() returns wrong icon for mimetype
Summary: KIO::iconNameForUrl() returns wrong icon for mimetype
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.76.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-23 05:45 UTC by Alexander Reinholdt
Modified: 2020-11-29 10:08 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.77


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Reinholdt 2020-11-23 05:45:00 UTC
SUMMARY


STEPS TO REPRODUCE
Use KIO::iconNameForUrl() to get icons for files located on a SMB server.

OBSERVED RESULT
KIO::iconNameForUrl() returns "network-workgroup" as icon name.

EXPECTED RESULT
The correct icon name for the mimetype of the file is returned. 

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
KDE Plasma Version: 5.20.3
KDE Frameworks Version: 5.76
Qt Version: 5.15.1

ADDITIONAL INFORMATION

This code snippet

QIcon icon = KDE::icon(KIO::iconNameForUrl(url));

yields the wrong icon for the mimetype for files on a SMB server, because KIO::iconNameForUrl(url) always returns "network-workgroup". Folders are handled correctly, though.
Comment 1 Nicolas Fella 2020-11-23 11:14:59 UTC
Can you give an example URL where this happens?
Comment 2 Alexander Reinholdt 2020-11-23 17:02:45 UTC
Sure. Any URL of the type

smb://SERVER/Path/filename.ending

should yield this result. Maybe other protocols are affected, too, but I haven't checked.

By the way, earlier versions of KIO did exactly what was expected. For example, if I compile Smb4K (my program) under Kubuntu 18.04, the icon name for the mimetype is correct. So, somewhere between version 5.44 and 5.76 there must have been a change that introduced this altered behavior.
Comment 3 Alexander Reinholdt 2020-11-23 18:13:01 UTC
I just tested it with KF5 5.68. There the problem already exists. Maybe this helps.
Comment 4 Nicolas Fella 2020-11-23 18:31:17 UTC
From looking at git log I'd say https://phabricator.kde.org/D27539 changed this
Comment 5 Méven Car 2020-11-24 09:43:10 UTC
I believe https://phabricator.kde.org/D27539 caused this.
Prior to it `db.mimeTypeForUrl(url).iconName();` would become the default icon for non-local files.
Comment 6 Bug Janitor Service 2020-11-24 10:24:41 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/227
Comment 7 David Faure 2020-11-29 10:08:45 UTC
Git commit 55465cc6639b7e5d83a9cdf30a010e0b677765c3 by David Faure, on behalf of Méven Car.
Committed on 29/11/2020 at 10:08.
Pushed by dfaure into branch 'master'.

KIO::iconNameForUrl: resolve icon for remote files based on name

Fix a regression introduced with eb20176d1a42eebd4c6c3cbdb5dca6a854760736
FIXED-IN: 5.77

M  +5    -2    autotests/kfileitemtest.cpp
M  +1    -1    src/core/global.cpp

https://invent.kde.org/frameworks/kio/commit/55465cc6639b7e5d83a9cdf30a010e0b677765c3