summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qicon.cpp3
-rw-r--r--src/gui/image/qiconloader.cpp15
2 files changed, 15 insertions, 3 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index c362d0dc3f..d3090b89f2 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -1245,6 +1245,9 @@ QString QIcon::fallbackThemeName()
themeSearchPath() containing an index.theme
file describing its contents.
+ \note This should be done before creating \l QGuiApplication, to ensure
+ correct initialization.
+
\sa fallbackThemeName(), themeSearchPaths(), themeName()
*/
void QIcon::setFallbackThemeName(const QString &name)
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index 27c82bc09f..4420027049 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -112,10 +112,9 @@ extern QFactoryLoader *qt_iconEngineFactoryLoader(); // qicon.cpp
void QIconLoader::ensureInitialized()
{
if (!m_initialized) {
+ if (!QGuiApplicationPrivate::platformTheme())
+ return; // it's too early: try again later (QTBUG-74252)
m_initialized = true;
-
- Q_ASSERT(qApp);
-
m_systemTheme = systemThemeName();
if (m_systemTheme.isEmpty())
@@ -125,6 +124,16 @@ void QIconLoader::ensureInitialized()
}
}
+/*!
+ \internal
+ Gets an instance.
+
+ \l QIcon::setFallbackThemeName() should be called before QGuiApplication is
+ created, to avoid a race condition (QTBUG-74252). When this function is
+ called from there, ensureInitialized() does not succeed because there
+ is no QPlatformTheme yet, so systemThemeName() is empty, and we don't want
+ m_systemTheme to get intialized to the fallback theme instead of the normal one.
+*/
QIconLoader *QIconLoader::instance()
{
iconLoaderInstance()->ensureInitialized();