From 9b9ab2af75e56587de2f217a8137da3cf9744ed0 Mon Sep 17 00:00:00 2001 From: m000z0rz Date: Wed, 20 May 2020 12:39:30 -0500 Subject: [PATCH] Fix script hanging when you stop a script with open listeners --- .../UserInterface/Debugger/ScriptInstance.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp b/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp index b38eb40f7..6bc9c174b 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp @@ -90,8 +90,11 @@ void CScriptInstance::ForceStop() { // Close all files and delete all hooked callbacks CGuard guard(m_CS); - CleanUp(); - SetState(STATE_STOPPED); + if (m_State != STATE_STOPPED) + { + CleanUp(); + SetState(STATE_STOPPED); + } } duk_context* CScriptInstance::DukContext() @@ -220,8 +223,7 @@ void CScriptInstance::StartEventLoop() RemoveListener(lpListener); } - CleanUp(); - SetState(STATE_STOPPED); + ForceStop(); } CScriptInstance::EVENT_STATUS @@ -529,8 +531,8 @@ void CScriptInstance::CloseAllFiles() for (size_t i = 0; i < nFiles; i++) { fclose(m_Files[i].fp); - m_Files.erase(m_Files.begin() + i); } + m_Files.clear(); } FILE* CScriptInstance::GetFilePointer(int fd)