Make gui panic alerts thread safe in linux.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6375 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice 2010-11-11 00:55:06 +00:00
parent 072a698856
commit 5078f430c3
4 changed files with 35 additions and 3 deletions

View File

@ -351,6 +351,8 @@ CFrame::CFrame(wxFrame* parent,
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
bFloatWindow[i] = false;
panic_event.Init();
if (ShowLogWindow) SConfig::GetInstance().m_InterfaceLogWindow = true;
// Give it a console early to show potential messages from this onward
@ -490,6 +492,8 @@ CFrame::~CFrame()
ClosePages();
panic_event.Shutdown();
delete m_Mgr;
}
@ -647,6 +651,14 @@ void CFrame::OnHostMessage(wxCommandEvent& event)
m_RenderParent->SetCursor(wxCURSOR_BLANK);
break;
#ifdef __WXGTK__
case IDM_PANIC:
bPanicResult = (wxYES == wxMessageBox(event.GetString(),
wxT("Warning"), event.GetInt() ? wxYES_NO : wxOK));
panic_event.Set();
break;
#endif
#if defined(HAVE_X11) && HAVE_X11
case WM_USER_STOP:
DoStop();

View File

@ -135,6 +135,11 @@ class CFrame : public CRenderFrame
void DoFullscreen(bool bF);
void ToggleDisplayMode (bool bFullscreen);
#ifdef __WXGTK__
Common::Event panic_event;
bool bPanicResult;
#endif
#if defined(HAVE_XRANDR) && HAVE_XRANDR
X11Utils::XRRConfiguration *m_XRRConfig;
#endif

View File

@ -237,6 +237,7 @@ enum
IDM_UPDATESTATUSBAR,
IDM_UPDATETITLE,
IDM_UPDATEBREAKPOINTS,
IDM_PANIC,
IDM_HOST_MESSAGE,
IDM_MPANEL, ID_STATUSBAR,

View File

@ -452,9 +452,23 @@ void Host_SysMessage(const char *fmt, ...)
bool wxMsgAlert(const char* caption, const char* text, bool yes_no, int /*Style*/)
{
return wxYES == wxMessageBox(wxString::FromAscii(text),
wxString::FromAscii(caption),
(yes_no)?wxYES_NO:wxOK);
#ifdef __WXGTK__
if (wxIsMainThread())
#endif
return wxYES == wxMessageBox(wxString::FromAscii(text),
wxString::FromAscii(caption),
(yes_no) ? wxYES_NO : wxOK);
#ifdef __WXGTK__
else
{
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_PANIC);
event.SetString(wxString::FromAscii(text));
event.SetInt(yes_no);
main_frame->GetEventHandler()->AddPendingEvent(event);
main_frame->panic_event.Wait();
return main_frame->bPanicResult;
}
#endif
}
// Accessor for the main window class