summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authorLu YaNing <luyaning@uniontech.com>2022-06-30 11:01:54 +0800
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2022-07-07 07:44:16 +0000
commit9e7c5670509ac81efdf78b691e70e5ce3d408a09 (patch)
tree4a71d219609e58f5fcfe5e33ba4a0c35da7ec811 /src/gui/image
parentfb8832de9c2d9cec08a83047137fbd316e6f7d1f (diff)
QIcon: remove icon from cache if the cached engine fails to load
An icon that is not null by the time it is inserted in the cache can become null, depending on the QIconEngine implementation. For example, when an application with a shortcut exists on the desktop, uninstall the application, and then install the application again, the acquisition of the application icon will fail. The reason is that after installing the application for the second time, the qtIconCache will not be updated when the icon is acquired. Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io> Pick-to: 5.15 6.2 6.3 6.4 Change-Id: I6dc8cf435815b92da270d74fe992843336af23e2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qicon.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 38e66b1dc0..08c4667c6c 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -1276,11 +1276,15 @@ void QIcon::setFallbackThemeName(const QString &name)
*/
QIcon QIcon::fromTheme(const QString &name)
{
- QIcon icon;
- if (qtIconCache()->contains(name)) {
- icon = *qtIconCache()->object(name);
- } else if (QDir::isAbsolutePath(name)) {
+ if (QIcon *cachedIcon = qtIconCache()->object(name)) {
+ if (!cachedIcon->isNull())
+ return *cachedIcon;
+ qtIconCache()->remove(name);
+ }
+
+ QIcon icon;
+ if (QDir::isAbsolutePath(name)) {
return QIcon(name);
} else {
QPlatformTheme * const platformTheme = QGuiApplicationPrivate::platformTheme();