src/gui/image/qiconloader.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 30 5dc02b23752f
--- a/src/gui/image/qiconloader.cpp	Fri Apr 16 15:50:13 2010 +0300
+++ b/src/gui/image/qiconloader.cpp	Mon May 03 13:17:34 2010 +0300
@@ -85,19 +85,30 @@
 }
 
 QIconLoader::QIconLoader() :
-        m_themeKey(1), m_supportsSvg(false)
+        m_themeKey(1), m_supportsSvg(false), m_initialized(false)
+{
+}
+
+// We lazily initialize the loader to make static icons
+// work. Though we do not officially support this.
+void QIconLoader::ensureInitialized()
 {
-    m_systemTheme = qt_guiPlatformPlugin()->systemIconThemeName();
-    if (m_systemTheme.isEmpty())
-        m_systemTheme = fallbackTheme();
+    if (!m_initialized) {
+        m_initialized = true;
 
+        Q_ASSERT(qApp);
+
+        m_systemTheme = qt_guiPlatformPlugin()->systemIconThemeName();
+        if (m_systemTheme.isEmpty())
+            m_systemTheme = fallbackTheme();
 #ifndef QT_NO_LIBRARY
-    QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterfaceV2_iid,
-                                     QLatin1String("/iconengines"),
-                                     Qt::CaseInsensitive);
-    if (iconFactoryLoader.keys().contains(QLatin1String("svg")))
-        m_supportsSvg = true;
+        QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterfaceV2_iid,
+                                         QLatin1String("/iconengines"),
+                                         Qt::CaseInsensitive);
+        if (iconFactoryLoader.keys().contains(QLatin1String("svg")))
+            m_supportsSvg = true;
 #endif //QT_NO_LIBRARY
+    }
 }
 
 QIconLoader *QIconLoader::instance()
@@ -339,6 +350,9 @@
 // Lazily load the icon
 void QIconLoaderEngine::ensureLoaded()
 {
+
+    iconLoaderInstance()->ensureInitialized();
+
     if (!(iconLoaderInstance()->themeKey() == m_key)) {
 
         while (!m_entries.isEmpty())