Frame: OnClose now handles asynchronous behaviour of DoStop().

This commit is contained in:
Jules Blok 2014-06-20 03:03:00 +02:00
parent 3266394dfb
commit b30d5dccbe
3 changed files with 21 additions and 10 deletions

View File

@ -352,7 +352,7 @@ CFrame::CFrame(wxFrame* parent,
, m_LogWindow(nullptr), m_LogConfigWindow(nullptr) , m_LogWindow(nullptr), m_LogConfigWindow(nullptr)
, m_FifoPlayerDlg(nullptr), UseDebugger(_UseDebugger) , m_FifoPlayerDlg(nullptr), UseDebugger(_UseDebugger)
, m_bBatchMode(_BatchMode), m_bEdit(false), m_bTabSplit(false), m_bNoDocking(false) , m_bBatchMode(_BatchMode), m_bEdit(false), m_bTabSplit(false), m_bNoDocking(false)
, m_bGameLoading(false) , m_bGameLoading(false), m_bClosing(false)
{ {
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++) for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
bFloatWindow[i] = false; bFloatWindow[i] = false;
@ -536,15 +536,18 @@ void CFrame::OnActive(wxActivateEvent& event)
void CFrame::OnClose(wxCloseEvent& event) void CFrame::OnClose(wxCloseEvent& event)
{ {
m_bClosing = true;
// Before closing the window we need to shut down the emulation core.
// We'll try to close this window again once that is done.
if (Core::GetState() != Core::CORE_UNINITIALIZED) if (Core::GetState() != Core::CORE_UNINITIALIZED)
{ {
DoStop(); DoStop();
if (Core::GetState() != Core::CORE_UNINITIALIZED) event.Veto();
return; return;
UpdateGUI();
} }
//Stop Dolphin from saving the minimized Xpos and Ypos // Stop Dolphin from saving the minimized Xpos and Ypos
if (main_frame->IsIconized()) if (main_frame->IsIconized())
main_frame->Iconize(false); main_frame->Iconize(false);

View File

@ -186,6 +186,7 @@ private:
bool m_bTabSplit; bool m_bTabSplit;
bool m_bNoDocking; bool m_bNoDocking;
bool m_bGameLoading; bool m_bGameLoading;
bool m_bClosing;
std::vector<std::string> drives; std::vector<std::string> drives;

View File

@ -832,8 +832,15 @@ void CFrame::OnPlay(wxCommandEvent& WXUNUSED (event))
void CFrame::OnRenderParentClose(wxCloseEvent& event) void CFrame::OnRenderParentClose(wxCloseEvent& event)
{ {
// Before closing the window we need to shut down the emulation core.
// We'll try to close this window again once that is done.
if (Core::GetState() != Core::CORE_UNINITIALIZED)
{
DoStop(); DoStop();
if (Core::GetState() == Core::CORE_UNINITIALIZED) event.Veto();
return;
}
event.Skip(); event.Skip();
} }
@ -1177,8 +1184,8 @@ void CFrame::OnStopped()
// Clear wiimote connection status from the status bar. // Clear wiimote connection status from the status bar.
GetStatusBar()->SetStatusText(" ", 1); GetStatusBar()->SetStatusText(" ", 1);
// If batch mode was specified on the command-line, exit now. // If batch mode was specified on the command-line or we were already closing, exit now.
if (m_bBatchMode) if (m_bBatchMode || m_bClosing)
Close(true); Close(true);
// If using auto size with render to main, reset the application size. // If using auto size with render to main, reset the application size.