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(); }