Fix script hanging when you stop a script with open listeners

This commit is contained in:
m000z0rz 2020-05-20 12:39:30 -05:00
parent 82716b247b
commit 9b9ab2af75
1 changed files with 7 additions and 5 deletions

View File

@ -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)