Skip to content

Commit

Permalink
sync: from linuxdeepin/dtkgui
Browse files Browse the repository at this point in the history
Synchronize source files from linuxdeepin/dtkgui.

Source-pull-request: linuxdeepin/dtkgui#234
  • Loading branch information
deepin-ci-robot committed Apr 19, 2024
1 parent eed3c72 commit 64752bc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion include/util/dicontheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 4 additions & 2 deletions src/util/dicontheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 7 additions & 4 deletions src/util/private/diconproxyengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,12 @@ void DIconProxyEngine::ensureEngine()
return;

static QMap<QString, QSet<QString>> 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
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 64752bc

Please sign in to comment.