diff --git a/pcsx2/IopBios.cpp b/pcsx2/IopBios.cpp index bc4cf15e2e..9ee8fd034c 100644 --- a/pcsx2/IopBios.cpp +++ b/pcsx2/IopBios.cpp @@ -257,6 +257,7 @@ namespace ioman { IOManDir *dir; }; + constexpr filedesc(): type(FILE_FREE), file(nullptr) {} operator bool() const { return type != FILE_FREE; } operator IOManFile*() const { return type == FILE_FILE ? file : NULL; } operator IOManDir*() const { return type == FILE_DIR ? dir : NULL; } @@ -326,7 +327,10 @@ namespace ioman { void reset() { for (int i = 0; i < maxfds; i++) - fds[i].close(); + { + if (fds[i]) + fds[i].close(); + } } bool is_host(const std::string path) diff --git a/pcsx2/System/SysCoreThread.cpp b/pcsx2/System/SysCoreThread.cpp index d69e5014a7..b04b0bc59d 100644 --- a/pcsx2/System/SysCoreThread.cpp +++ b/pcsx2/System/SysCoreThread.cpp @@ -30,6 +30,7 @@ #include "Utilities/PageFaultSource.h" #include "Utilities/Threading.h" +#include "IopBios.h" #ifdef __WXMSW__ # include @@ -64,12 +65,14 @@ SysCoreThread::~SysCoreThread() void SysCoreThread::Cancel( bool isBlocking ) { m_hasActiveMachine = false; + R3000A::ioman::reset(); _parent::Cancel(); } bool SysCoreThread::Cancel( const wxTimeSpan& span ) { m_hasActiveMachine = false; + R3000A::ioman::reset(); return _parent::Cancel( span ); } @@ -123,6 +126,7 @@ void SysCoreThread::ResetQuick() m_resetVirtualMachine = true; m_hasActiveMachine = false; + R3000A::ioman::reset(); } void SysCoreThread::Reset() @@ -291,6 +295,7 @@ void SysCoreThread::OnCleanupInThread() m_hasActiveMachine = false; m_resetVirtualMachine = true; + R3000A::ioman::reset(); // FIXME: temporary workaround for deadlock on exit, which actually should be a crash vu1Thread.WaitVU(); GetCorePlugins().Close();