diff --git a/include/util/dicontheme.h b/include/util/dicontheme.h index abcb08c..c48a79b 100644 --- a/include/util/dicontheme.h +++ b/include/util/dicontheme.h @@ -17,7 +17,8 @@ namespace DIconTheme enum Option { DontFallbackToQIconFromTheme = 1 << 0, IgnoreBuiltinIcons = 1 << 1, - IgnoreDciIcons = 1 << 2 + IgnoreDciIcons = 1 << 2, + DisableIconCache = 1 << 3 }; Q_DECLARE_FLAGS(Options, Option) diff --git a/src/util/dicontheme.cpp b/src/util/dicontheme.cpp index 7e96ab4..3fe7033 100644 --- a/src/util/dicontheme.cpp +++ b/src/util/dicontheme.cpp @@ -186,10 +186,12 @@ QIcon DIconTheme::Cached::findQIcon(const QString &iconName, Options options, co } auto newIcon = new QIcon(DIconTheme::findQIcon(iconName, options)); - data->cache.insert(cacheKey, newIcon); - if (newIcon->isNull()) + if (newIcon->isNull()) { return fallback; + } else { + data->cache.insert(cacheKey, newIcon); + } return *newIcon; } diff --git a/src/util/private/diconproxyengine.cpp b/src/util/private/diconproxyengine.cpp index 707983e..6eceaa6 100644 --- a/src/util/private/diconproxyengine.cpp +++ b/src/util/private/diconproxyengine.cpp @@ -226,9 +226,12 @@ void DIconProxyEngine::ensureEngine() return; static QMap> nonCache; - const auto it = nonCache.find(theme); - if (it != nonCache.end() && it->contains(m_iconName)) - return; + if (Q_UNLIKELY(!m_option.testFlag(DIconTheme::DisableIconCache))) + { + const auto it = nonCache.find(theme); + if (it != nonCache.end() && it->contains(m_iconName)) + return; + } if (m_iconEngine) { // dci => dci @@ -271,7 +274,7 @@ void DIconProxyEngine::ensureEngine() m_iconEngine = createXdgProxyIconEngine(m_iconName); } #endif - if (!m_iconEngine ) { + if (!m_iconEngine && !nonCache[theme].contains(m_iconName)) { qErrnoWarning("create icon [%s] engine failed.[theme:%s] nonCache[theme].size[%d]", m_iconName.toUtf8().data(), theme.toUtf8().data(), nonCache[theme].size());