SWORD25: Remove thumbnails from the cache when saving a new game

This commit is contained in:
md5 2011-05-05 20:14:21 +03:00
parent 2af3759a78
commit 0ef807146e
3 changed files with 23 additions and 0 deletions

View File

@ -336,6 +336,9 @@ bool PersistenceService::saveGame(uint slotID, const Common::String &screenshotF
// Savegameinformationen für diesen Slot aktualisieren.
_impl->readSlotSavegameInformation(slotID);
// Empty the cache, to remove old thumbnails
Kernel::getInstance()->getResourceManager()->emptyThumbnailCache();
// Erfolg signalisieren.
return true;
}

View File

@ -147,6 +147,21 @@ void ResourceManager::emptyCache() {
}
}
void ResourceManager::emptyThumbnailCache() {
// Scan through the resource list
Common::List<Resource *>::iterator iter = _resources.begin();
while (iter != _resources.end()) {
if ((*iter)->getFileName().hasPrefix("/saves")) {
// Unlock the thumbnail
while ((*iter)->getLockCount() > 0)
(*iter)->release();
// Delete the thumbnail
iter = deleteResource(*iter);
} else
++iter;
}
}
/**
* Returns a requested resource. If any error occurs, returns NULL
* @param FileName Filename of resource

View File

@ -81,6 +81,11 @@ public:
**/
void emptyCache();
/**
* Removes all the savegame thumbnails from the cache
**/
void emptyThumbnailCache();
/**
* Writes the names of all currently locked resources to the log file
*/