diff --git a/common/include/Utilities/SafeArray.h b/common/include/Utilities/SafeArray.h index 01cb1bd742..dd6f6192ae 100644 --- a/common/include/Utilities/SafeArray.h +++ b/common/include/Utilities/SafeArray.h @@ -454,4 +454,4 @@ public: // For lack of a better place for now (they depend on SafeList so they can't go in StringUtil) extern void SplitString( SafeList& dest, const wxString& src, const wxString& delims ); -extern void JoinString( wxString& dest, const SafeList& src, const wxString& separator ); +extern wxString JoinString( const SafeList& src, const wxString& separator ); diff --git a/common/include/Utilities/StringHelpers.h b/common/include/Utilities/StringHelpers.h index 5556465473..39b309e2fc 100644 --- a/common/include/Utilities/StringHelpers.h +++ b/common/include/Utilities/StringHelpers.h @@ -69,7 +69,8 @@ extern wxString fromAscii( const char* src ); extern const wxRect wxDefaultRect; extern void SplitString( wxArrayString& dest, const wxString& src, const wxString& delims, wxStringTokenizerMode mode = wxTOKEN_RET_EMPTY_ALL ); -extern void JoinString( wxString& dest, const wxArrayString& src, const wxString& separator ); +extern wxString JoinString( const wxArrayString& src, const wxString& separator ); +extern wxString JoinString( const wxChar** src, const wxString& separator ); extern wxString ToString( const wxPoint& src, const wxString& separator=L"," ); extern wxString ToString( const wxSize& src, const wxString& separator=L"," ); diff --git a/common/src/Utilities/StringHelpers.cpp b/common/src/Utilities/StringHelpers.cpp index 5859ad9441..80590e4bdd 100644 --- a/common/src/Utilities/StringHelpers.cpp +++ b/common/src/Utilities/StringHelpers.cpp @@ -61,24 +61,46 @@ void SplitString( wxArrayString& dest, const wxString& src, const wxString& deli // // Note: wxWidgets 2.9 / 3.0 has a wxJoin function, but we're using 2.8 so I had to make // my own. -void JoinString( wxString& dest, const SafeList& src, const wxString& separator ) +wxString JoinString( const SafeList& src, const wxString& separator ) { + wxString dest; for( int i=0, len=src.GetLength(); i GlobalCommands; @@ -466,9 +469,6 @@ protected: ScopedPtr m_RecentIsoList; ScopedPtr m_Resources; - Threading::Mutex m_mtx_Resources; - Threading::Mutex m_mtx_LoadingGameDB; - public: // Executor Thread for complex VM/System tasks. This thread is used to execute such tasks // in parallel to the main message pump, to allow the main pump to run without fear of diff --git a/pcsx2/gui/AppGameDatabase.cpp b/pcsx2/gui/AppGameDatabase.cpp index e20a21ccb7..63a6c76516 100644 --- a/pcsx2/gui/AppGameDatabase.cpp +++ b/pcsx2/gui/AppGameDatabase.cpp @@ -129,6 +129,7 @@ void DBLoaderHelper::ReadGames() } while(!m_reader.Eof()) { // Fill game data, find new game, repeat... + pthread_testcancel(); pxReadLine(m_reader, m_dest, m_intermediate); m_dest.Trim(true).Trim(false); if( m_dest.IsEmpty() ) continue; diff --git a/pcsx2/gui/AppInit.cpp b/pcsx2/gui/AppInit.cpp index 13fa658d5f..f2f52e31ce 100644 --- a/pcsx2/gui/AppInit.cpp +++ b/pcsx2/gui/AppInit.cpp @@ -470,9 +470,10 @@ typedef void (wxEvtHandler::*pxInvokeAppMethodEventFunction)(Pcsx2AppMethodEvent typedef void (wxEvtHandler::*pxStuckThreadEventHandler)(pxMessageBoxEvent&); // -------------------------------------------------------------------------------------- -// CompressThread_gzip +// GameDatabaseLoaderThread // -------------------------------------------------------------------------------------- class GameDatabaseLoaderThread : public pxThread + , EventListener_AppStatus { typedef pxThread _parent; @@ -480,7 +481,11 @@ protected: gzFile m_gzfp; public: - GameDatabaseLoaderThread() : pxThread( L"GameDatabaseLoader" ) {} + GameDatabaseLoaderThread() + : pxThread( L"GameDatabaseLoader" ) + { + } + virtual ~GameDatabaseLoaderThread() throw() { _parent::Cancel(); @@ -489,13 +494,20 @@ public: protected: void ExecuteTaskInThread() { + Sleep(2); wxGetApp().GetGameDatabase(); } void OnCleanupInThread() { + _parent::OnCleanupInThread(); wxGetApp().DeleteThread(this); } + + void AppStatusEvent_OnExit() + { + Block(); + } }; bool Pcsx2App::OnInit() @@ -640,8 +652,8 @@ void Pcsx2App::PrepForExit() if( m_ScheduledTermination ) return; m_ScheduledTermination = true; - SysExecutorThread.ShutdownQueue(); DispatchEvent( AppStatus_Exiting ); + SysExecutorThread.ShutdownQueue(); m_timer_Termination->Start( 500 ); @@ -711,6 +723,8 @@ void Pcsx2App::CleanupResources() while( wxGetLocale() != NULL ) delete wxGetLocale(); + m_mtx_LoadingGameDB.Wait(); + ScopedLock lock(m_mtx_Resources); m_Resources = NULL; } @@ -829,6 +843,6 @@ struct CrtDebugBreak } }; -//CrtDebugBreak breakAt( 737 ); +//CrtDebugBreak breakAt( 909 ); #endif diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index 0949c52b3b..8f1339a107 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -213,17 +213,55 @@ wxWindowID SwapOrReset_CdvdSrc( wxWindow* owner, CDVD_SourceType newsrc ) return result; } +static wxString JoinFiletypes( const wxChar** src ) +{ + wxString dest; + while( *src != NULL ) + { + if( *src[0] == 0 ) continue; + if( !dest.IsEmpty() ) + dest += L";"; + + dest += wxsFormat(L"*.%s", *src); + + #ifdef __LINUX__ + // omgosh! linux is CaSE SeNSiTiVE!! + dest += wxsFormat(L";*.%s", *src).MakeUpper(); + #endif + + ++src; + } + + return dest; +} + // Returns FALSE if the user canceled the action. bool MainEmuFrame::_DoSelectIsoBrowser( wxString& result ) { - static const wxChar* isoFilterTypes = - L"All Supported (.iso .mdf .nrg .bin .img .dump)|*.iso;*.mdf;*.nrg;*.bin;*.img;*.dump|" - L"Disc Images (.iso .mdf .nrg .bin .img)|*.iso;*.mdf;*.nrg;*.bin;*.img|" - L"Blockdumps (.dump)|*.dump|" - L"All Files (*.*)|*.*"; + static const wxChar* isoSupportedTypes[] = + { + L"iso", L"mdf", L"nrg", L"bin", L"img", NULL + }; + const wxString isoSupportedLabel( JoinString(isoSupportedTypes, L" ") ); + const wxString isoSupportedList( JoinFiletypes(isoSupportedTypes) ); + + wxArrayString isoFilterTypes; + + isoFilterTypes.Add(wxsFormat(_("All Supported (%s)"), (isoSupportedLabel + L" .dump").c_str())); + isoFilterTypes.Add(isoSupportedList + L";*.dump"); + + isoFilterTypes.Add(wxsFormat(_("Disc Images (%s)"), isoSupportedLabel.c_str() )); + isoFilterTypes.Add(isoSupportedList); + + isoFilterTypes.Add(wxsFormat(_("Blockdumps (%s)"), L".dump" )); + isoFilterTypes.Add(L"*.dump"); + + isoFilterTypes.Add(_("All Files (*.*)")); + isoFilterTypes.Add(L"*.*"); + wxFileDialog ctrl( this, _("Select CDVD source iso..."), g_Conf->Folders.RunIso.ToString(), wxEmptyString, - isoFilterTypes, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); + JoinString(isoFilterTypes, L"|"), wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( ctrl.ShowModal() != wxID_CANCEL ) { @@ -237,12 +275,10 @@ bool MainEmuFrame::_DoSelectIsoBrowser( wxString& result ) bool MainEmuFrame::_DoSelectELFBrowser() { - static const wxChar* elfFilterTypes = - L"ELF Files (.elf)|*.elf|" - L"All Files (*.*)|*.*"; + static const wxChar* elfFilterType = L"ELF Files (.elf)|*.elf;*.ELF|"; wxFileDialog ctrl( this, _("Select ELF file..."), g_Conf->Folders.RunELF.ToString(), wxEmptyString, - elfFilterTypes, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); + (wxString)elfFilterType + L"|" + _("All Files (*.*)") + L"|*.*", wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( ctrl.ShowModal() != wxID_CANCEL ) {