Merge pull request #558 from ctrlaltca/memory_limit

Limit pixmap cache size to 2047MB; fix #555
This commit is contained in:
Gavin Bisesi 2015-01-16 12:09:00 -05:00
commit 7ef5f2d3a4
3 changed files with 9 additions and 2 deletions

View file

@ -52,8 +52,9 @@ GeneralSettingsPage::GeneralSettingsPage()
pixmapCacheLabel = new QLabel;
pixmapCacheEdit = new QSpinBox;
pixmapCacheEdit->setMinimum(64);
pixmapCacheEdit->setMaximum(8192);
pixmapCacheEdit->setMinimum(PIXMAPCACHE_SIZE_MIN);
// 2047 is the max value to avoid overflowing of QPixmapCache::setCacheLimit(int size)
pixmapCacheEdit->setMaximum(PIXMAPCACHE_SIZE_MAX);
pixmapCacheEdit->setSingleStep(64);
pixmapCacheEdit->setValue(settingsCache->getPixmapCacheSize());
pixmapCacheEdit->setSuffix(" MB");

View file

@ -24,6 +24,10 @@ SettingsCache::SettingsCache()
picDownload = settings->value("personal/picturedownload", true).toBool();
picDownloadHq = settings->value("personal/picturedownloadhq", false).toBool();
pixmapCacheSize = settings->value("personal/pixmapCacheSize", PIXMAPCACHE_SIZE_DEFAULT).toInt();
//sanity check
if(pixmapCacheSize < PIXMAPCACHE_SIZE_MIN || pixmapCacheSize > PIXMAPCACHE_SIZE_MAX)
pixmapCacheSize = PIXMAPCACHE_SIZE_DEFAULT;
picUrl = settings->value("personal/picUrl", PIC_URL_DEFAULT).toString();
picUrlHq = settings->value("personal/picUrlHq", PIC_URL_HQ_DEFAULT).toString();
picUrlFallback = settings->value("personal/picUrlFallback", PIC_URL_FALLBACK).toString();

View file

@ -9,6 +9,8 @@
#define PIC_URL_HQ_FALLBACK "http://mtgimage.com/set/!setcode!/!name!.jpg"
// size should be a multiple of 64
#define PIXMAPCACHE_SIZE_DEFAULT 256
#define PIXMAPCACHE_SIZE_MIN 64
#define PIXMAPCACHE_SIZE_MAX 2047
class QSettings;