Bug 342906 - KIconEngine causes QIcon::hasThemeIcon to be always true
Summary: KIconEngine causes QIcon::hasThemeIcon to be always true
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kiconthemes
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Christoph Feck
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-16 10:48 UTC by Martin Flöser
Modified: 2015-02-18 09:46 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Flöser 2015-01-16 10:48:09 UTC
KIconEngine is used by frameworkintegration to provide a platform specific QIconEngine. Unfortunately a feature of KIconEngine breaks QIcon::hasThemeIcon. By always rendering the "unknown" icon the checks performed by QIcon::hasThemeIcon fail as it compares against a null QIcon. Also the fallback icon from QIcon::fromTheme is never picked.

It is unexpected that using a platform theme breaks the API of QIcon. Also it breaks the fallback handling in KWindowSystem::icon.

Reproducible: Always

Steps to Reproduce:
1. Use kwin
2. Use Xephyr


Actual Results:  
Window decoration of Xephyr doesn't pick the xorg fallback icon, but a "missing icon" icon

Expected Results:  
Window decoration of Xephyr doesn't pick the xorg fallback icon
Comment 1 Martin Flöser 2015-01-16 11:04:30 UTC
Additional info:
QIcon::hasThemeIcon compares for QIcon::isNull while QIcon::fromTheme checks the availableSizes to determine whether the fallback icon should be returned.
Comment 2 Christoph Feck 2015-01-20 22:21:45 UTC
So how can this be fixed? If QIcon::fromTheme needs to return a null icon for QIcon::hasThemeIcon to fail correctly, then QIcon::fromTheme cannot return a fallback icon. Or did I miss something?
Comment 3 Alexander Görtz 2015-01-31 23:28:38 UTC
Hi, indeed this looks a bit strange here is the check for hasThemeIcon:
https://qt.gitorious.org/qt/qtbase/source/73a1e8c60d894701f34806cc4b847aa2814bf389:src/gui/image/qicon.cpp#L1198-1203

and this the used fromTheme function:
https://qt.gitorious.org/qt/qtbase/source/73a1e8c60d894701f34806cc4b847aa2814bf389:src/gui/image/qicon.cpp#L1167-1188

So as the hasThemeIcon function  calls fromTheme with no fallback the Null Icon should be returned if the theme has no icon for the given name (availableSizes.isEmpty). So to fix this "KDE" should not report available sizes for icons that are definitely not in the current theme. I'm not sure this is fixable on the qt side as they rely on the platform theme implementation. I guess this whole QPA stuff moves a lot of responsibility to the KDE devs ;).
Comment 4 Olivier Goffart 2015-02-06 17:40:51 UTC
QIcon::fromTheme need to return a fallback icon only if the fallback is passed as parametter.
what that means is that means is that the returned icon by the custom engine from the platform theme must be emtpy.
Comment 5 Olivier Goffart 2015-02-17 14:40:48 UTC
My attempt:  https://reviewboard.kde.org/r/122608/