Commit dcd8f861 authored by Halla Rempt's avatar Halla Rempt

Fix crash in the icon cache on exit

Only use the icon cache when Qt >= 5.9; this cache causes crashes
with Qt 5.6 and 5.7 for sure, not tested with 5.9.
parent 3c0d6f95
......@@ -28,21 +28,26 @@
#include <QDebug>
#include <KoIcon.h>
#if QT_VERSION >= 0x050900
#define CACHE_ICONS
#endif
namespace KisIconUtils
{
#if defined CACHE_ICONS
static QMap<QString, QIcon> s_cache;
#endif
static QMap<qint64, QString> s_icons;
QIcon loadIcon(const QString &name)
{
#if defined CACHE_ICONS
QMap<QString, QIcon>::const_iterator cached = s_cache.constFind(name);
if (cached != s_cache.constEnd()) {
return cached.value();
}
#endif
// try load themed icon
QColor background = qApp->palette().background().color();
bool useDarkIcons = background.value() > 100;
......@@ -69,7 +74,9 @@ QIcon loadIcon(const QString &name)
if (QFile(resname).exists()) {
QIcon icon(resname);
s_icons.insert(icon.cacheKey(), name);
#if defined CACHE_ICONS
s_cache.insert(name, icon);
#endif
return icon;
}
}
......@@ -108,14 +115,18 @@ QIcon loadIcon(const QString &name)
icon.addFile(p.second, QSize(size, size));
}
s_icons.insert(icon.cacheKey(), name);
#if defined CACHE_ICONS
s_cache.insert(name, icon);
#endif
return icon;
}
QIcon icon = QIcon::fromTheme(name);
qWarning() << "\tfalling back on QIcon::FromTheme:" << name;
s_icons.insert(icon.cacheKey(), name);
#if defined CACHE_ICONS
s_cache.insert(name, icon);
#endif
return icon;
}
......
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