diff --git a/source/gui/video.cpp b/source/gui/video.cpp index 5d1596c2..055244aa 100644 --- a/source/gui/video.cpp +++ b/source/gui/video.cpp @@ -249,30 +249,11 @@ void CVideo::cleanup(void) m_aaBuffer[i].release(); } for(u8 i = 0; i < m_defaultWaitMessages.size(); i++) - { - if(m_defaultWaitMessages[i].data.get()) - m_defaultWaitMessages[i].data.release(); - } - if(m_frameBuf[0] != NULL) - { - free(MEM_K1_TO_K0(m_frameBuf[0])); - m_frameBuf[0] = NULL; - } - if(m_frameBuf[1] != NULL) - { - free(MEM_K1_TO_K0(m_frameBuf[1])); - m_frameBuf[0] = NULL; - } - if(m_stencil != NULL) - { - MEM1_free(m_stencil); - m_stencil = NULL; - } - if(m_fifo != NULL) - { - MEM1_free(m_fifo); - m_fifo = NULL; - } + m_defaultWaitMessages[i].data.release(); + free(MEM_K1_TO_K0(m_frameBuf[0])); + free(MEM_K1_TO_K0(m_frameBuf[1])); + MEM1_free(m_stencil); + MEM1_free(m_fifo); } void CVideo::prepareAAPass(int aaStep) diff --git a/source/main.cpp b/source/main.cpp index 4ecd1516..719bb176 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -136,13 +136,9 @@ int main(int argc, char **argv) ret = menu.main(); } } - Open_Inputs(); //reinit wiimote + if(ret == 1) + Open_Inputs(); //reinit wiimote } while (ret == 1); - - WifiGecko_Close(); - - Nand::Instance()->Disable_Emu(); - Nand::DestroyInstance(); Sys_Exit(); return 0; diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 94356097..fa4eee72 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -462,8 +462,13 @@ void CMenu::init(void) } } +bool cleaned_up = false; + void CMenu::cleanup(bool ios_reload) { + if(cleaned_up) + return; + m_cf.stopCoverLoader(); m_cf.clear(); ClearGameSoundThreadStack(); @@ -500,6 +505,7 @@ void CMenu::cleanup(bool ios_reload) _deinitNetwork(); ClearLogBuffer(); + cleaned_up = true; gprintf(" \nMemory cleaned up\n"); } diff --git a/source/menu/menu_main.cpp b/source/menu/menu_main.cpp index 43e43b71..6a9a1fab 100644 --- a/source/menu/menu_main.cpp +++ b/source/menu/menu_main.cpp @@ -790,14 +790,6 @@ int CMenu::main(void) m_cf.mouse(m_vid, chan, -1, -1); } } - _showWaitMessage(); - - gprintf("Invalidate GX\n"); - - GX_InvVtxCache(); - GX_InvalidateTexAll(); - gprintf("Clear coverflow\n"); - m_cf.clear(); gprintf("Saving configuration files\n"); m_cfg.save(); m_cat.save(); @@ -807,8 +799,7 @@ int CMenu::main(void) coverStatus = LWP_THREAD_NULL; if(coverstatus_stack.get()) coverstatus_stack.release(); - - gprintf("Done with main\n"); + cleanup(); return m_reload ? 1 : 0; }