diff --git a/src/kicontheme.cpp b/src/kicontheme.cpp --- a/src/kicontheme.cpp +++ b/src/kicontheme.cpp @@ -69,20 +69,6 @@ } Q_COREAPP_STARTUP_FUNCTION(initRCCIconTheme) -// Set the icon theme fallback to breeze -// Most of our apps use "lots" of icons that most of the times -// are only available with breeze, we still honour the user icon -// theme but if the icon is not found there, we go to breeze -// since it's almost sure it'll be there -static void setBreezeFallback() -{ -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) - QIcon::setFallbackThemeName(QStringLiteral("breeze")); -#endif -} - -Q_COREAPP_STARTUP_FUNCTION(setBreezeFallback) - class Q_DECL_HIDDEN KIconTheme::KIconThemePrivate { public: @@ -107,6 +93,7 @@ Q_GLOBAL_STATIC(QString, _theme) Q_GLOBAL_STATIC(QStringList, _theme_list) + /** * A subdirectory in an icon theme. */ @@ -264,6 +251,23 @@ KIconTheme::KIconTheme(const QString &name, const QString &appName, const QString &basePathHint) : d(new KIconThemePrivate) { +// Set the icon theme fallback to breeze +// Most of our apps use "lots" of icons that most of the times +// are only available with breeze, we still honour the user icon +// theme but if the icon is not found there, we go to breeze +// since it's almost sure it'll be there. +// Doing this as Q_COREAPP_STARTUP_FUNCTION is too soon as +// at that point QPlatformTheme is not instantiated yet and +// breaks the internal status of QIconLoader +// see https://bugreports.qt.io/browse/QTBUG-74252 +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) + static bool s_fallbackThemeInitialized; + if (!s_fallbackThemeInitialized) { + QIcon::setFallbackThemeName(QStringLiteral("breeze")); + s_fallbackThemeInitialized = true; + } +#endif + d->mInternalName = name; QStringList themeDirs;