SyncEvents: ensure MB & Mouse have removed their events for a restart

This commit is contained in:
tomcw 2020-12-12 17:46:36 +00:00
parent 30d3269fbf
commit 0ddb1917aa
3 changed files with 15 additions and 7 deletions

View File

@ -1649,6 +1649,9 @@ void MB_Destroy()
for (int id=0; id<kNumSyncEvents; id++)
{
if (g_syncEvent[id] && g_syncEvent[id]->m_active)
g_SynchronousEventMgr.Remove(id);
delete g_syncEvent[id];
g_syncEvent[id] = NULL;
}

View File

@ -17,6 +17,7 @@ public:
void Initialize(LPBYTE pCxRomPeripheral, UINT uSlot);
// void Uninitialize();
void Reset();
UINT GetSlot(void) { return m_uSlot; }
static BYTE __stdcall IORead(WORD PC, WORD uAddr, BYTE bWrite, BYTE uValue, ULONG nExecutedCycles);
static BYTE __stdcall IOWrite(WORD PC, WORD uAddr, BYTE bWrite, BYTE uValue, ULONG nExecutedCycles);

View File

@ -653,19 +653,23 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
MB_Reset();
LogFileOutput("Main: MB_Reset()\n");
if (g_bRestart)
{
CMouseInterface* pMouseCard = GetCardMgr().GetMouseCard();
if (pMouseCard)
{
pMouseCard->Reset(); // Deassert any pending IRQs - GH#514
LogFileOutput("Main: CMouseInterface::Uninitialize()\n");
// dtor removes event from g_SynchronousEventMgr - do before g_SynchronousEventMgr.Reset()
GetCardMgr().Remove( pMouseCard->GetSlot() );
LogFileOutput("Main: CMouseInterface::dtor\n");
}
_ASSERT(g_SynchronousEventMgr.GetHead() == NULL);
g_SynchronousEventMgr.Reset();
}
DSUninit();
LogFileOutput("Main: DSUninit()\n");
if (g_bRestart)
g_SynchronousEventMgr.Reset();
if (g_bHookSystemKey)
{
UninitHookThread();