From c0deb93a261f8ec0dede896fda077e9c29c55be6 Mon Sep 17 00:00:00 2001 From: deepin-ci-robot Date: Tue, 23 Apr 2024 01:27:05 +0000 Subject: [PATCH] sync: from linuxdeepin/dtkgui Synchronize source files from linuxdeepin/dtkgui. Source-pull-request: https://github.com/linuxdeepin/dtkgui/pull/234 --- include/util/dicontheme.h | 3 ++- src/util/dicontheme.cpp | 6 ++++-- src/util/private/diconproxyengine.cpp | 11 +++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/util/dicontheme.h b/include/util/dicontheme.h index abcb08c..b96eec0 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, + IgnoreIconCache = 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..3a281c7 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::IgnoreIconCache))) + { + 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());