[KPhotoAlbum] Bug in image cache size computation
Robert Krawitz
rlk at alum.mit.edu
Sun Sep 27 00:55:10 BST 2015
The number of items in the image cache is computed incorrectly if the
image cache size is 2048 MB or greater; it's effectively zero due to
signedness problems. Performance is much better with this fix.
Also, why the hard upper limit of 4096 MB? I have 16 GB of RAM in my
laptop, and might as well take advantage of it.
diff --git a/Viewer/ImageDisplay.cpp b/Viewer/ImageDisplay.cpp
index 1775efb..77be9a9 100644
--- a/Viewer/ImageDisplay.cpp
+++ b/Viewer/ImageDisplay.cpp
@@ -567,7 +567,7 @@ void Viewer::ImageDisplay::setImageList( const DB::FileNameList& list )
void Viewer::ImageDisplay::updatePreload()
{
- const int cacheSize = ( Settings::SettingsData::instance()->viewerCacheSize() * 1024 * 1024 ) / (width()*height()*4);
+ const int cacheSize = (int) ((long long) ( Settings::SettingsData::instance()->viewerCacheSize() * 1024ll * 1024ll ) / (width()*height()*4));
bool cacheFull = (m_cache.count() > cacheSize);
int incr = ( m_forward ? 1 : -1 );
--
Robert Krawitz <rlk at alum.mit.edu>
*** MIT Engineers A Proud Tradition http://mitathletics.com ***
Member of the League for Programming Freedom -- http://ProgFree.org
Project lead for Gutenprint -- http://gimp-print.sourceforge.net
"Linux doesn't dictate how I work, I dictate how Linux works."
--Eric Crampton
More information about the Kphotoalbum
mailing list