[KPhotoAlbum] Bug in image cache size computation
miika.turkia at gmail.com
Sun Sep 27 09:42:25 BST 2015
On Sat, Sep 26, 2015 at 7:55 PM, Robert Krawitz <rlk at alum.mit.edu> wrote:
> 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);
You really had me fooled with this one. Not easy at all to decipher,
what is going on before getting the morning fix of caffeine. Anyway,
you could as well change to unsigned cacheSize while you are at it.
But that would probably take a bit more effort to change on the
required other places.
More information about the Kphotoalbum