diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index c1961797779..a597d1e8b67 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -633,14 +633,16 @@ QIconEngine *QIconLoader::iconEngine(const QString &iconName) const qCDebug(lcIconLoader) << "Icon is not available from theme or fallback theme."; if (auto *platformTheme = QGuiApplicationPrivate::platformTheme()) { qCDebug(lcIconLoader) << "Trying platform engine."; - iconEngine.reset(platformTheme->createIconEngine(iconName)); + std::unique_ptr themeEngine(platformTheme->createIconEngine(iconName)); + if (themeEngine && !themeEngine->isNull()) { + iconEngine = std::move(themeEngine); + qCDebug(lcIconLoader) << "Icon provided by platform engine."; + } } - // We need to maintain the invariant that the QIcon has a valid engine - if (!iconEngine || iconEngine->isNull()) - iconEngine.reset(new QIconLoaderEngine(iconName)); - else - qCDebug(lcIconLoader) << "Icon provided by platform engine."; } + // We need to maintain the invariant that the QIcon has a valid engine + if (!iconEngine) + iconEngine.reset(new QIconLoaderEngine(iconName)); qCDebug(lcIconLoader) << "Resulting engine" << iconEngine.get(); return iconEngine.release();