Commit aa0035d0 authored by Martin Klapetek's avatar Martin Klapetek
Browse files

Fix looking up icons

What the current code does is looking for the best match, storing it
into QString path...and then overwrite it with empty string on next run
if the icon is not found in the current dir. So we need to check first
if the icon is available in the theme and only then store the path,
otherwise empty string gets returned non-deterministically.

This also fixes case of some missing icons in Plasma Next.

REVIEW: 118415
BUG: 330845
parent 6c042988
......@@ -417,6 +417,7 @@ bool KIconTheme::hasContext(KIconLoader::Context context) const
QString KIconTheme::iconPath(const QString &name, int size, KIconLoader::MatchType match) const
{
QString path;
QString tempPath; // used to cache icon path if it exists
int delta = -INT_MAX; // current icon size delta of 'icon'
int dw = INT_MAX; // icon size delta of current directory
KIconThemeDir *dir;
......@@ -477,10 +478,13 @@ QString KIconTheme::iconPath(const QString &name, int size, KIconLoader::MatchTy
}
}
path = dir->iconPath(name);
if (path.isEmpty()) {
// cache the result of iconPath() call which checks if file exists
tempPath = dir->iconPath(name);
if (tempPath.isEmpty()) {
continue;
}
path = tempPath;
// if we got in MatchExact that far, we find no better
if (match == KIconLoader::MatchExact) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment