Review Request 128397: KIconEngine: Fix QIcon::hasThemeIcon always returning true

David Rosca nowrep at gmail.com
Fri Jul 8 08:40:06 UTC 2016



> On July 7, 2016, 9:59 p.m., David Faure wrote:
> > autotests/kiconengine_unittest.cpp, line 69
> > <https://git.reviewboard.kde.org/r/128397/diff/1/?file=471281#file471281line69>
> >
> >     What's the problem if name() returns "invalid-icon-name" here?

```
bool QIcon::hasThemeIcon(const QString &name)
{
    QIcon icon = fromTheme(name);

    return icon.name() == name;
}
```

And QIcon::name() returns just the QIconEngine::iconName(). Qt's default icon engine returns empty iconName() when the icon cannot be found.


> On July 7, 2016, 9:59 p.m., David Faure wrote:
> > src/kiconengine.cpp, line 119
> > <https://git.reviewboard.kde.org/r/128397/diff/1/?file=471283#file471283line119>
> >
> >     I'm worried that this might do a (slow?) lookup every time it's called?

It's only called from QIcon::name() and QIcon::hasThemeIcon(), so it shouldn't be problem. Maybe the lookup can be done only once and mIconName emptied when the icon is not found, if it would be needed?


- David


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/128397/#review97181
-----------------------------------------------------------


On July 7, 2016, 9:55 p.m., David Rosca wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/128397/
> -----------------------------------------------------------
> 
> (Updated July 7, 2016, 9:55 p.m.)
> 
> 
> Review request for KDE Frameworks and Olivier Goffart.
> 
> 
> Repository: kiconthemes
> 
> 
> Description
> -------
> 
> QIcon::hasThemeIcon(name) checks if QIcon::name() == name, so icon engine must return empty string when icon doesn't exist.
> Also implement IsNullHook for Qt 5.7. Comes with autotest.
> 
> 
> Diffs
> -----
> 
>   autotests/CMakeLists.txt 0c7de50 
>   autotests/kiconengine_unittest.cpp PRE-CREATION 
>   src/kiconengine.h 21a63f5 
>   src/kiconengine.cpp 3ccc7d1 
> 
> Diff: https://git.reviewboard.kde.org/r/128397/diff/
> 
> 
> Testing
> -------
> 
> Issue was reported in https://bugreports.qt.io/browse/QTBUG-54595
> Also similar issue https://bugs.kde.org/show_bug.cgi?id=365031 (there is a check for hasThemeIcon before using the icon, but it returns true which results in invalid icon name -> no icon).
> 
> 
> Thanks,
> 
> David Rosca
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20160708/70be547d/attachment.html>


More information about the Kde-frameworks-devel mailing list