diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index 365ef10a79..06ecb1d637 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -147,9 +147,7 @@ private: GameInfoCache::~GameInfoCache() { - for (auto iter = info_.begin(); iter != info_.end(); iter++) { - delete iter->second; - } + Clear(); } void GameInfoCache::Init() { @@ -174,6 +172,27 @@ void GameInfoCache::Decimate() { // TODO } +void GameInfoCache::Clear() { + gameInfoWQ_->Flush(); + for (auto iter = info_.begin(); iter != info_.end(); iter++) { + lock_guard lock(iter->second->lock); + if (!iter->second->pic0TextureData.empty()) { + iter->second->pic0TextureData.clear(); + } + if (iter->second->pic0Texture) { + delete iter->second->pic0Texture; + iter->second->pic0Texture = 0; + } + if (!iter->second->pic1TextureData.empty()) { + iter->second->pic1TextureData.clear(); + } + if (iter->second->pic1Texture) { + delete iter->second->pic1Texture; + iter->second->pic1Texture = 0; + } + } +} + void GameInfoCache::FlushBGs() { for (auto iter = info_.begin(); iter != info_.end(); iter++) { lock_guard lock(iter->second->lock); diff --git a/UI/GameInfoCache.h b/UI/GameInfoCache.h index e17e815208..75d0dd72c6 100644 --- a/UI/GameInfoCache.h +++ b/UI/GameInfoCache.h @@ -67,6 +67,7 @@ public: // This creates a background worker thread! void Init(); void Shutdown(); + void Clear(); // 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, diff --git a/UI/MenuScreens.cpp b/UI/MenuScreens.cpp index 10a33e3199..d5ccdfe125 100644 --- a/UI/MenuScreens.cpp +++ b/UI/MenuScreens.cpp @@ -245,7 +245,11 @@ void MenuScreen::render() { // TODO: Save when setting changes, rather than when we quit NativeShutdown(); // TODO: Need a more elegant way to quit +#ifdef _WIN32 + ExitProcess(0); +#else exit(0); +#endif } if (UIButton(GEN_ID, vlinear, w, 0, "www.ppsspp.org", ALIGN_RIGHT)) { diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 6d03c0971c..4c844321d0 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -422,6 +422,7 @@ void NativeUpdate(InputState &input) void NativeDeviceLost() { + g_gameInfoCache.Clear(); screenManager->deviceLost(); gl_lost(); glstate.Restore();