From 29ccbfe14014a93a30f4e3d9967b3c63eb8cd911 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Mon, 29 Jun 2015 19:36:30 +0100 Subject: [PATCH] Fix plugin error handling for wx3.0 on Windows This prevents a PCSX2 lock up that requires Task Manager to kill. It seems the messagebox intercepts the GSframe's close event, hides itself and then leaves you with no way of ending PCSX2 normally. So close the GS frame before the message box appears. --- pcsx2/gui/AppMain.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index 136a77a060..af297b914f 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -660,10 +660,23 @@ void Pcsx2App::HandleEvent(wxEvtHandler* handler, wxEventFunction func, wxEvent& // ---------------------------------------------------------------------------- catch( Exception::PluginOpenError& ex ) { - // Should need to do much here -- all systems should be in an inert and (sorta safe!) state. - - Console.Error( ex.FormatDiagnosticMessage() ); - AddIdleEvent( PluginInitErrorEvent(ex) ); + // It might be possible for there to be no GS Frame, but I don't really know. This does + // prevent PCSX2 from locking up on a Windows wxWidgets 3.0 build. My conjecture is this: + // 1. Messagebox appears + // 2. Either a close or hide signal for gsframe gets sent to messagebox. + // 3. Message box hides itself without exiting the modal event loop, therefore locking up + // PCSX2. This probably happened in the BIOS error case above as well. + // So the idea is to explicitly close the gsFrame before the modal MessageBox appears and + // intercepts the close message. Only for wx3.0 though - it sometimes breaks linux wx2.8. +#if wxMAJOR_VERSION >= 3 + if (GSFrame* gsframe = wxGetApp().GetGsFramePtr()) + gsframe->Close(); +#endif + Console.Error(ex.FormatDiagnosticMessage()); + + // Make sure it terminates properly for nogui users. + if (wxGetApp().HasGUI()) + AddIdleEvent(PluginInitErrorEvent(ex)); } // ---------------------------------------------------------------------------- catch( Exception::PluginInitError& ex )