summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authorFan PengCheng <fanpengcheng@uniontech.com>2021-04-21 21:15:16 +0800
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-04-23 03:49:28 +0000
commit4dc7102c8410f5699af93b6c55ba1c7df7755bc2 (patch)
tree42ed8a290b407630497dac4b2f27d5fc398b4625 /src/gui/image
parent3458dd2d4773de379ea4c8309096d6e2cfd8a339 (diff)
Avoid adding null-objects to the icon cache
When we can't get the icon for the first time, we would use the data in the cache later, and we will never get the new icon when the system theme is updated while the application is running. Pick-to: 6.1 Change-Id: I839ad9983918561a1dc6bc842f85477bba53f64a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qicon.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 2b607ac5be..9c554dd513 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -1323,9 +1323,9 @@ QIcon QIcon::fromTheme(const QString &name)
bool hasUserTheme = QIconLoader::instance()->hasUserTheme();
QIconEngine * const engine = (platformTheme && !hasUserTheme) ? platformTheme->createIconEngine(name)
: new QIconLoaderEngine(name);
- QIcon *cachedIcon = new QIcon(engine);
- icon = *cachedIcon;
- qtIconCache()->insert(name, cachedIcon);
+ icon = QIcon(engine);
+ if (!icon.isNull())
+ qtIconCache()->insert(name, new QIcon(icon));
}
return icon;