Theme: cache the QIcon::fromTheme
authorOlivier Goffart <ogoffart@woboq.com>
Tue, 20 Oct 2015 11:24:11 +0000 (13:24 +0200)
committerOlivier Goffart <ogoffart@woboq.com>
Tue, 20 Oct 2015 11:24:11 +0000 (13:24 +0200)
We are calling that every time we draw the folder delegate.
Which is a lot when the sync is runing and the progress bar is moving

src/libsync/theme.cpp

index 6cb127567512a321eb984aabe7e2fad07c1e86fa..094d6a09d912e853558c019ebf384ba09239f736 100644 (file)
@@ -124,14 +124,14 @@ QIcon Theme::themeIcon( const QString& name, bool sysTray ) const
         flavor = QLatin1String("colored");
     }
 
-    if( QIcon::hasThemeIcon( name )) {
-        // use from theme
-        return QIcon::fromTheme( name );
-    }
-
     QString key = name + "," + flavor;
     QIcon & cached = _iconCache[key];
     if (cached.isNull()) {
+        if(QIcon::hasThemeIcon(name)) {
+            // use from theme
+            return cached = QIcon::fromTheme(name);
+        }
+
         QList<int> sizes;
         sizes <<16 << 22 << 32 << 48 << 64 << 128 << 256;
         foreach (int size, sizes) {