GameInfoCache: Clear snd together with bg

This commit is contained in:
Henrik Rydgard 2014-06-22 09:56:27 +02:00
parent 6ec74ef99e
commit b1ae00c56f
2 changed files with 20 additions and 4 deletions

View File

@ -501,6 +501,7 @@ void GameInfoCache::Clear() {
lock_guard lock(iter->second->lock);
if (!iter->second->pic0TextureData.empty()) {
iter->second->pic0TextureData.clear();
iter->second->pic0DataLoaded = false;
}
if (iter->second->pic0Texture) {
delete iter->second->pic0Texture;
@ -508,6 +509,7 @@ void GameInfoCache::Clear() {
}
if (!iter->second->pic1TextureData.empty()) {
iter->second->pic1TextureData.clear();
iter->second->pic1DataLoaded = false;
}
if (iter->second->pic1Texture) {
delete iter->second->pic1Texture;
@ -515,11 +517,17 @@ void GameInfoCache::Clear() {
}
if (!iter->second->iconTextureData.empty()) {
iter->second->iconTextureData.clear();
iter->second->iconDataLoaded = false;
}
if (iter->second->iconTexture) {
delete iter->second->iconTexture;
iter->second->iconTexture = 0;
}
if (!iter->second->sndFileData.empty()) {
iter->second->sndFileData.clear();
iter->second->sndDataLoaded = false;
}
}
info_.clear();
}
@ -529,19 +537,27 @@ void GameInfoCache::FlushBGs() {
lock_guard lock(iter->second->lock);
if (!iter->second->pic0TextureData.empty()) {
iter->second->pic0TextureData.clear();
iter->second->pic0DataLoaded = false;
}
if (iter->second->pic0Texture) {
delete iter->second->pic0Texture;
iter->second->pic0Texture = 0;
}
if (!iter->second->pic1TextureData.empty()) {
iter->second->pic1TextureData.clear();
iter->second->pic1DataLoaded = false;
}
if (iter->second->pic1Texture) {
delete iter->second->pic1Texture;
iter->second->pic1Texture = 0;
}
iter->second->wantFlags &= ~GAMEINFO_WANTBG;
if (!iter->second->sndFileData.empty()) {
iter->second->sndFileData.clear();
iter->second->sndDataLoaded = false;
}
iter->second->wantFlags &= ~(GAMEINFO_WANTBG | GAMEINFO_WANTSND);
}
}

View File

@ -168,11 +168,11 @@ public:
// All data in GameInfo including iconTexture may be zero the first time you call this
// but filled in later asynchronously in the background. So keep calling this,
// redrawing the UI often. Only set wantBG if you really want it because
// it's big. bgTextures may be discarded over time as well.
// redrawing the UI often. Only set flags to GAMEINFO_WANTBG or WANTSND if you really want them
// because they're big. bgTextures and sound may be discarded over time as well.
GameInfo *GetInfo(const std::string &gamePath, int wantFlags);
void Decimate(); // Deletes old info.
void FlushBGs(); // Gets rid of all BG textures.
void FlushBGs(); // Gets rid of all BG textures. Also gets rid of bg sounds.
// TODO - save cache between sessions
void Save();