From 70e2fe4029e13eec51aeace49dbe2615db4af4e1 Mon Sep 17 00:00:00 2001 From: Fangxun Zhao Date: Tue, 11 Aug 2026 22:01:17 +0800 Subject: [PATCH] fix(appmgr): defer apps until theme icon resolves MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Add resolvedIconPath() to check if a theme icon name resolves to a real icon via QIcon::fromTheme 2. Defer newly added app items with unresolved theme icons to the pending queue and start the check timer 3. Refresh the theme icon cache via IconUtils::tryUpdateIconCache() on each pending check so icons appearing after startup become visible 4. Promote pending items once their icon resolves; force-process leftovers after the 120s timeout 5. Extend the pending-item timeout from 60s to 120s to cover slow theme initialization Log: Defer app items with unresolvable theme icons until the icon becomes available, then promote them. Influence: Apps with null icons now show once the icon is available. fix(appmgr): 主题图标未解析的应用延迟到图标可用后再添加 1. 新增 resolvedIconPath(),通过 QIcon::fromTheme 判断主题图标名是否可解析为真实图标 2. 图标未解析的新增应用项先放入待处理队列并启动检查定时器 3. 每次待处理检查时通过 IconUtils::tryUpdateIconCache() 刷新主题图标缓存,使启动后新出现的图标可见 4. 图标可解析后立即提升待处理项,超过 120 秒超时则强制处理剩余项 5. 待处理项超时从 60 秒延长至 120 秒,以覆盖主题初始化较慢的场景 Log: 将主题图标无法解析的应用延迟处理,待图标可用后再提升。 PMS: BUG-371833 Influence: 图标为 null 的应用在图标可用后正常显示。 --- src/ddeintegration/appmgr.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/ddeintegration/appmgr.cpp b/src/ddeintegration/appmgr.cpp index 6e8833ba..c2e70654 100644 --- a/src/ddeintegration/appmgr.cpp +++ b/src/ddeintegration/appmgr.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "appmgr.h" +#include "iconutils.h" #include #include @@ -10,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -222,7 +224,13 @@ bool AppMgr::removeFromDesktop(const QString &desktopId) // For: bug-347859 bool AppMgr::waitForIcon(const QString &desktopId, const QString &iconName) { - if (desktopId.isEmpty() || !QFileInfo(iconName).isAbsolute() || QFileInfo::exists(iconName)) { + // Defer the row until its icon is resolvable: an absolute path that does + // not exist yet, or a theme-name icon QIcon cannot resolve yet (theme not + // initialized at startup). For: bug-347859, bug-371833. + const bool resolvable = QFileInfo(iconName).isAbsolute() + ? QFileInfo::exists(iconName) + : iconName.isEmpty() || !QIcon::fromTheme(iconName).isNull(); + if (desktopId.isEmpty() || resolvable) { cancelPendingAppItem(desktopId); return false; } @@ -261,9 +269,15 @@ void AppMgr::checkPendingAppItems() { ++m_checkCount; + // Reload theme search paths so icons appearing after startup become visible. + IconUtils::tryUpdateIconCache(); QStringList readyItems; for (auto it = m_pendingAppItems.begin(); it != m_pendingAppItems.end();) { - if (QFileInfo::exists(it.value())) { + const QString &iconName = it.value(); + const bool ready = QFileInfo(iconName).isAbsolute() + ? QFileInfo::exists(iconName) + : !QIcon::fromTheme(iconName).isNull(); + if (ready) { readyItems.append(it.key()); it = m_pendingAppItems.erase(it); } else { @@ -271,7 +285,8 @@ void AppMgr::checkPendingAppItems() } } - if (m_checkCount >= 20) { + // 120s timeout (3s interval): cover slow theme initialization. + if (m_checkCount >= 40) { readyItems.append(m_pendingAppItems.keys()); m_pendingAppItems.clear(); }