From 7a3071c4bcf95b03a95ad20bdfd239f4690fa5f1 Mon Sep 17 00:00:00 2001 From: Fan PengCheng Date: Wed, 21 Apr 2021 21:15:16 +0800 Subject: [PATCH] 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. Change-Id: I839ad9983918561a1dc6bc842f85477bba53f64a Reviewed-by: Volker Hilsheimer (cherry picked from commit 4dc7102c8410f5699af93b6c55ba1c7df7755bc2) Reviewed-by: Qt Cherry-pick Bot --- src/gui/image/qicon.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 2b607ac5be7..9c554dd513a 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;