From 7f0039d6460c7d666bd6cd9a66fb3122eff2d5ad Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Wed, 9 Sep 2009 16:52:11 +0000 Subject: [PATCH] Two more lockup fixes, and changing plugins takes effect without restarting now. :) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1801 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/Utilities/Exceptions.h | 11 ------- common/src/Utilities/Console.cpp | 5 ++-- pcsx2/MTGS.cpp | 1 + pcsx2/System.cpp | 2 +- pcsx2/gui/App.h | 4 +-- pcsx2/gui/AppConfig.cpp | 4 +-- pcsx2/gui/HostGui.cpp | 7 ++++- pcsx2/gui/Panels/MiscPanelStuff.cpp | 3 +- pcsx2/gui/main.cpp | 41 +++++++++++++++++++++------ 9 files changed, 48 insertions(+), 30 deletions(-) diff --git a/common/include/Utilities/Exceptions.h b/common/include/Utilities/Exceptions.h index 404a197c9e..2e8f5b9c54 100644 --- a/common/include/Utilities/Exceptions.h +++ b/common/include/Utilities/Exceptions.h @@ -46,17 +46,6 @@ namespace Exception public: virtual ~BaseException() throw()=0; // the =0; syntax forces this class into "abstract" mode. - /* - // copy construct - BaseException( const BaseException& src ) : - m_message_diag( src.m_message_diag ), - m_message_user( src.m_message_user ), - m_stacktrace( src.m_stacktrace ) - { } - - // trivial constructor, to appease the C++ multiple virtual inheritence gods. (CMVIGs!) - BaseException() {}*/ - const wxString& DiagMsg() const { return m_message_diag; } const wxString& UserMsg() const { return m_message_user; } diff --git a/common/src/Utilities/Console.cpp b/common/src/Utilities/Console.cpp index 82de85078a..177fe586e1 100644 --- a/common/src/Utilities/Console.cpp +++ b/common/src/Utilities/Console.cpp @@ -22,7 +22,6 @@ using namespace std; namespace Console { MutexLock m_writelock; - std::string m_format_buffer; bool __fastcall Write( Colors color, const wxString& fmt ) { @@ -44,14 +43,14 @@ namespace Console // ------------------------------------------------------------------------ __forceinline void __fastcall _Write( const char* fmt, va_list args ) { - ScopedLock locker( m_writelock ); + std::string m_format_buffer; vssprintf( m_format_buffer, fmt, args ); Write( wxString::FromUTF8( m_format_buffer.c_str() ) ); } __forceinline void __fastcall _WriteLn( const char* fmt, va_list args ) { - ScopedLock locker( m_writelock ); + std::string m_format_buffer; vssprintf( m_format_buffer, fmt, args ); m_format_buffer += "\n"; Write( wxString::FromUTF8( m_format_buffer.c_str() ) ); diff --git a/pcsx2/MTGS.cpp b/pcsx2/MTGS.cpp index fbff5d5250..d75008b13e 100644 --- a/pcsx2/MTGS.cpp +++ b/pcsx2/MTGS.cpp @@ -226,6 +226,7 @@ void mtgsThreadObject::Cancel() { //SendSimplePacket( GS_RINGTYPE_QUIT, 0, 0, 0 ); //SetEvent(); + //m_sem_finished.WaitGui(); PersistentThread::Cancel(); } diff --git a/pcsx2/System.cpp b/pcsx2/System.cpp index 08291d2538..f97e7ce1dd 100644 --- a/pcsx2/System.cpp +++ b/pcsx2/System.cpp @@ -378,7 +378,7 @@ void SysReset() { Console::Status( "Resetting PS2 virtual machine..." ); - SysShutdown(); + SysEndExecution(); StateRecovery::Clear(); ElfCRC = 0; diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index b55b0e6384..41f32117f9 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -260,7 +260,7 @@ public: void PostMenuAction( MenuIdentifiers menu_id ) const; void Ping() const; - void ApplySettings(); + void ApplySettings( const AppConfig& newconf ); void LoadSettings(); void SaveSettings(); @@ -305,7 +305,7 @@ protected: void OnSemaphorePing( wxCommandEvent& evt ); void OnMessageBox( pxMessageBoxEvent& evt ); - void OnKeyDown( wxKeyEvent& evt ); + void OnEmuKeyDown( wxKeyEvent& evt ); // ---------------------------------------------------------------------------- // Override wx default exception handling behavior diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index fa107095aa..caf296f4b6 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -457,7 +457,7 @@ void AppConfig::Apply() Folders.Savestates.Mkdir(); Folders.Snapshots.Mkdir(); - g_Conf->EmuOptions.BiosFilename = g_Conf->FullpathToBios(); + EmuOptions.BiosFilename = FullpathToBios(); // Update the compression attribute on the Memcards folder. // Memcards generally compress very well via NTFS compression. @@ -596,7 +596,7 @@ void AppConfig_ReloadGlobalSettings( bool overwrite ) if( !overwrite ) wxGetApp().LoadSettings(); - wxGetApp().ApplySettings(); + wxGetApp().ApplySettings( *g_Conf ); g_Conf->Folders.Logs.Mkdir(); wxString newlogname( Path::Combine( g_Conf->Folders.Logs.ToString(), L"emuLog.txt" ) ); diff --git a/pcsx2/gui/HostGui.cpp b/pcsx2/gui/HostGui.cpp index 88c8cac918..416ed95325 100644 --- a/pcsx2/gui/HostGui.cpp +++ b/pcsx2/gui/HostGui.cpp @@ -53,8 +53,13 @@ static wxString GetGSStateFilename() return Path::Combine( g_Conf->Folders.Savestates, wxsFormat( L"/%8.8X.%d.gs", ElfCRC, StatesC ) ); } -void Pcsx2App::OnKeyDown( wxKeyEvent& evt ) +// This handles KeyDown messages from the emu/gs window. +void Pcsx2App::OnEmuKeyDown( wxKeyEvent& evt ) { + // Block "Stray" messages, which get sent after the emulation state has been killed off. + // (happens when user hits multiple keys quickly before the emu thread can respond) + if( !EmulationInProgress() ) return; + switch( evt.GetKeyCode() ) { case WXK_ESCAPE: diff --git a/pcsx2/gui/Panels/MiscPanelStuff.cpp b/pcsx2/gui/Panels/MiscPanelStuff.cpp index da59335e19..4ba040e80a 100644 --- a/pcsx2/gui/Panels/MiscPanelStuff.cpp +++ b/pcsx2/gui/Panels/MiscPanelStuff.cpp @@ -78,9 +78,8 @@ bool Panels::StaticApplyState::ApplyPage( int pageid, bool saveOnSuccess ) // If an exception is thrown above, this code below won't get run. // (conveniently skipping any option application! :D) - *g_Conf = confcopy; UseAdminMode = g_ApplyState.UseAdminMode; - wxGetApp().ApplySettings(); + wxGetApp().ApplySettings( confcopy ); if( saveOnSuccess ) wxGetApp().SaveSettings(); } diff --git a/pcsx2/gui/main.cpp b/pcsx2/gui/main.cpp index 455224bbcf..a989c9b0d7 100644 --- a/pcsx2/gui/main.cpp +++ b/pcsx2/gui/main.cpp @@ -375,7 +375,7 @@ bool Pcsx2App::OnInit() Connect( pxEVT_CallStackBox, pxMessageBoxEventThing( Pcsx2App::OnMessageBox ) ); Connect( pxEVT_SemaphorePing, wxCommandEventHandler( Pcsx2App::OnSemaphorePing ) ); - Connect( pxID_Window_GS, wxEVT_KEY_DOWN, wxKeyEventHandler( Pcsx2App::OnKeyDown ) ); + Connect( pxID_Window_GS, wxEVT_KEY_DOWN, wxKeyEventHandler( Pcsx2App::OnEmuKeyDown ) ); // User/Admin Mode Dual Setup: // Pcsx2 now supports two fundamental modes of operation. The default is Classic mode, @@ -410,7 +410,7 @@ bool Pcsx2App::OnInit() m_MainFrame->Show(); SysInit(); - ApplySettings(); + ApplySettings( *g_Conf ); InitPlugins(); } // ---------------------------------------------------------------------------- @@ -511,20 +511,23 @@ void Pcsx2App::HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& // to handle window closures) bool Pcsx2App::PrepForExit() { + SysShutdown(); + MemoryCard::Shutdown(); + CleanupMess(); + + m_ProgramLogBox = NULL; + m_MainFrame = NULL; + return true; } int Pcsx2App::OnExit() { - m_ProgramLogBox = NULL; - m_MainFrame = NULL; - - MemoryCard::Shutdown(); + PrepForExit(); if( g_Conf != NULL ) SaveSettings(); - CleanupMess(); return wxApp::OnExit(); } @@ -547,8 +550,30 @@ Pcsx2App::~Pcsx2App() } -void Pcsx2App::ApplySettings() +void Pcsx2App::ApplySettings( const AppConfig& newconf ) { + + if( &newconf != g_Conf ) + { + // Need to unload the current emulation state if the user changed plugins, because + // the whole plugin system needs to be re-loaded. + + const PluginInfo* pi = tbl_PluginInfo-1; + while( ++pi, pi->shortname != NULL ) + { + if( newconf.FullpathTo( pi->id ) != g_Conf->FullpathTo( pi->id ) ) + break; + } + if( pi->shortname != NULL ) + { + // [TODO] : Post notice that this shuts down existing emulation. + SysEndExecution(); + safe_delete( g_plugins ); + LoadPlugins(); + } + *g_Conf = newconf; + } + g_Conf->Apply(); if( m_MainFrame != NULL ) m_MainFrame->ApplySettings();