Add sanity check to ResourceCache::updateTotalSize

This commit is contained in:
Zach Pomerantz 2016-04-21 10:41:04 -07:00
parent cba5bff89e
commit 2fd88d9fe1
2 changed files with 6 additions and 1 deletions

View file

@ -424,6 +424,11 @@ void ResourceCache::removeResource(const QUrl& url, qint64 size) {
void ResourceCache::updateTotalSize(const qint64& deltaSize) {
_totalResourcesSize += deltaSize;
// Sanity checks
assert(_totalResourcesSize >= 0);
assert(_totalResourcesSize < (1024 * BYTES_PER_GIGABYTES));
emit dirty();
}

View file

@ -50,7 +50,7 @@ static const qint64 DEFAULT_UNUSED_MAX_SIZE = 100 * BYTES_PER_MEGABYTES;
static const qint64 DEFAULT_UNUSED_MAX_SIZE = 1024 * BYTES_PER_MEGABYTES;
#endif
static const qint64 MIN_UNUSED_MAX_SIZE = 0;
static const qint64 MAX_UNUSED_MAX_SIZE = 10 * BYTES_PER_GIGABYTES;
static const qint64 MAX_UNUSED_MAX_SIZE = MAXIMUM_CACHE_SIZE;
// We need to make sure that these items are available for all instances of
// ResourceCache derived classes. Since we can't count on the ordering of