Sophie

Sophie

distrib > Mandriva > 2009.0 > x86_64 > media > main-testing-src > by-pkgid > 69501fee79f575b9818fcbd4bf2bb6c4 > files > 11

kdelibs4-4.2.4-0.2mdv2009.0.src.rpm

diff -p -up plasma/svg.cpp.svgcache plasma/svg.cpp
--- plasma/svg.cpp.svgcache	2009-03-17 10:27:16.000000000 -0300
+++ plasma/svg.cpp	2009-03-17 10:33:22.000000000 -0300
@@ -72,7 +72,8 @@ class SvgPrivate
               renderer(0),
               multipleImages(false),
               themed(false),
-              applyColors(false)
+              applyColors(false),
+              lastModified(0)
         {
         }
 
@@ -183,7 +184,7 @@ class SvgPrivate
             Theme *theme = Theme::defaultTheme();
             QPixmap p;
 
-            if (theme->findInCache(id, p)) {
+            if (theme->findInCache(id, p, lastModified)) {
                 //kDebug() << "found cached version of " << id << p.size();
                 return p;
             } else {
@@ -407,6 +408,7 @@ class SvgPrivate
         bool multipleImages;
         bool themed;
         bool applyColors;
+        unsigned int lastModified;
 };
 
 QHash<QString, SharedSvgRenderer::Ptr> SvgPrivate::s_renderers;
@@ -572,6 +574,13 @@ bool Svg::containsMultipleImages() const
 
 void Svg::setImagePath(const QString &svgFilePath)
 {
+    if(!svgFilePath.contains("widgets/") && !svgFilePath.contains("dialogs/")) {
+        QFile f(svgFilePath);
+        QFileInfo info(f);
+
+        d->lastModified = info.lastModified().toTime_t();
+    }
+
     d->setImagePath(svgFilePath, this);
     d->eraseRenderer();
     emit repaintNeeded();
diff -p -up plasma/theme.cpp.svgcache plasma/theme.cpp
--- plasma/theme.cpp.svgcache	2009-03-17 10:26:58.000000000 -0300
+++ plasma/theme.cpp	2009-03-17 10:34:13.000000000 -0300
@@ -565,6 +565,14 @@ bool Theme::findInCache(const QString &k
     return d->useCache() && d->pixmapCache->find(key, pix);
 }
 
+bool Theme::findInCache(const QString &key, QPixmap &pix, unsigned int lastModified)
+{
+    if(lastModified > d->pixmapCache->timestamp())
+        d->discardCache();
+
+    return findInCache(key, pix);
+}
+
 void Theme::insertIntoCache(const QString& key, const QPixmap& pix)
 {
     if (d->useCache()) {
diff -p -up plasma/theme.h.svgcache plasma/theme.h
--- plasma/theme.h.svgcache	2009-03-17 10:27:03.000000000 -0300
+++ plasma/theme.h	2009-03-17 10:30:24.000000000 -0300
@@ -186,6 +186,13 @@ class PLASMA_EXPORT Theme : public QObje
         bool findInCache(const QString &key, QPixmap &pix);
 
         /**
+         * This is an overloaded member provided to check with file timestamp
+         * where cache is still valid.
+         * @return true when pixmap was found and loaded from cache, false otherwise
+         **/
+        bool findInCache(const QString &key, QPixmap &pix, unsigned int lastModified);
+
+        /**
          * Insert specified pixmap into the cache.
          * If the cache already contains pixmap with the specified key then it is
          *  overwritten.