From f75a3c8f6084fab8a4dedeecf6a142357c1fe1cd Mon Sep 17 00:00:00 2001 From: Peter Tissen Date: Sat, 12 Jul 2014 13:52:37 +0200 Subject: [PATCH] unload modules upon stopping I guess we won't find out what's wrong if we don't let it fail --- rpcs3/Emu/SysCalls/ModuleManager.cpp | 13 ++++++++++++- rpcs3/Emu/System.cpp | 3 +-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/SysCalls/ModuleManager.cpp b/rpcs3/Emu/SysCalls/ModuleManager.cpp index fa03dd18cb..25523e33b2 100644 --- a/rpcs3/Emu/SysCalls/ModuleManager.cpp +++ b/rpcs3/Emu/SysCalls/ModuleManager.cpp @@ -271,7 +271,7 @@ initialized(false) ModuleManager::~ModuleManager() { - m_mod_init.clear(); + UnloadModules(); } bool ModuleManager::IsLoadedFunc(u32 id) @@ -332,6 +332,7 @@ u32 ModuleManager::GetFuncNumById(u32 id) return id; } +//to load the default modules after calling this call Init() again void ModuleManager::UnloadModules() { for (u32 i = 0; i<3; ++i) @@ -345,6 +346,16 @@ void ModuleManager::UnloadModules() } } + //reset state of the module manager + //this could be done by calling the destructor and then a placement-new + //to avoid repeating the initial values here but the defaults aren't + //complicated enough to complicate this by using the placement-new + m_mod_init.clear(); + m_max_module_id = 0; + m_module_2_count = 0; + initialized = false; + memset(m_modules, 0, 3 * 0xFF * sizeof(Module*)); + std::lock_guard lock(m_funcs_lock); m_modules_funcs_list.clear(); } diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index b44a4000a4..45c0f0dee3 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -415,8 +415,7 @@ void Emulator::Stop() GetKeyboardManager().Close(); GetMouseManager().Close(); GetCallbackManager().Clear(); - // TODO: not all modules unload cleanly, so we're not unloading them for now - //GetModuleManager().UnloadModules(); + GetModuleManager().UnloadModules(); CurGameInfo.Reset(); Memory.Close();