Make the emulation stop asynchronous to prevent deadlocks.

This may expose bugs which relied on the Main Thread to be suspended in the stopping state.
This commit is contained in:
Jules Blok
2014-06-20 02:43:57 +02:00
parent ff6fa68b71
commit 3266394dfb
7 changed files with 127 additions and 82 deletions

View File

@ -425,6 +425,7 @@ CFrame::CFrame(wxFrame* parent,
Movie::SetInputManip(TASManipFunction);
State::SetOnAfterLoadCallback(OnAfterLoadCallback);
Core::SetOnStoppedCallback(OnStoppedCallback);
// Setup perspectives
if (g_pCodeWindow)
@ -692,6 +693,10 @@ void CFrame::OnHostMessage(wxCommandEvent& event)
case WM_USER_STOP:
DoStop();
break;
case IDM_STOPPED:
OnStopped();
break;
}
}
@ -904,6 +909,16 @@ void OnAfterLoadCallback()
}
}
void OnStoppedCallback()
{
// warning: this gets called from the EmuThread, so we should only queue things to do on the proper thread
if (main_frame)
{
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_STOPPED);
main_frame->GetEventHandler()->AddPendingEvent(event);
}
}
void TASManipFunction(SPADStatus *PadStatus, int controllerID)
{
if (main_frame)