[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdegames/kpat/libkcardgame
From:       Parker Coates <parker.coates () kdemail ! net>
Date:       2011-02-01 20:57:16
Message-ID: 20110201205716.965B6AC8C2 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1218293 by coates:

Get rid of createCache() as it was only being used once.

 M  +0 -1      CMakeLists.txt  
 D             common.cpp  
 M  +0 -6      common.h  
 M  +20 -1     kabstractcarddeck.cpp  


--- trunk/KDE/kdegames/kpat/libkcardgame/CMakeLists.txt #1218292:1218293
@@ -1,5 +1,4 @@
 set( libkcardgame_SRCS
-    common.cpp
     kabstractcarddeck.cpp
     kcard.cpp
     kcarddeck.cpp
--- trunk/KDE/kdegames/kpat/libkcardgame/common.h #1218292:1218293
@@ -20,18 +20,12 @@
 #ifndef COMMON_P_H
 #define COMMON_P_H
 
-class KCardTheme;
-
-class KImageCache;
 #include <KSharedDataCache>
 
 #include <QDataStream>
 class QString;
-class QSize;
 
 
-KImageCache * createCache( const KCardTheme & theme );
-
 template<class T>
 bool cacheFind( KSharedDataCache * cache, const QString & key, T * result )
 {
--- trunk/KDE/kdegames/kpat/libkcardgame/kabstractcarddeck.cpp #1218292:1218293
@@ -37,6 +37,8 @@
 
 namespace
 {
+    const QString cacheNameTemplate( "libkcardgame-themes/%1" );
+    const QString timeStampKey( "libkcardgame_timestamp" );
     const QString unscaledSizeKey( "libkcardgame_unscaledsize" );
     const QString lastUsedSizeKey( "libkcardgame_lastusedsize" );
 
@@ -452,8 +454,25 @@
         }
 
         delete d->cache;
-        d->cache = createCache( d->theme );
 
+        QString cacheName = QString( cacheNameTemplate ).arg( theme.dirName() );
+        d->cache = new KImageCache( cacheName, 3 * 1024 * 1024 );
+        d->cache->setEvictionPolicy( KSharedDataCache::EvictLeastRecentlyUsed );
+
+        // Enabling the pixmap cache has caused issues: we were getting back
+        // different pixmaps than we had inserted. We keep a partial cache of the
+        // pixmaps in KAbstractCardDeck already, so the builtin pixmap caching
+        // doesn't really add that much benefit anyway.
+        d->cache->setPixmapCaching( false );
+
+        QDateTime cacheTimeStamp;
+        if ( !cacheFind( d->cache, timeStampKey, &cacheTimeStamp )
+            || cacheTimeStamp < theme.lastModified() )
+        {
+            d->cache->clear();
+            cacheInsert( d->cache, timeStampKey, theme.lastModified() );
+        }
+
         d->originalCardSize = d->unscaledCardSize();
         Q_ASSERT( !d->originalCardSize.isNull() );
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic