diff --git a/common/include/Utilities/StringHelpers.h b/common/include/Utilities/StringHelpers.h index 39b309e2fc..c6fce8a698 100644 --- a/common/include/Utilities/StringHelpers.h +++ b/common/include/Utilities/StringHelpers.h @@ -108,6 +108,7 @@ struct ParsedAssignmentString extern bool pxParseAssignmentString( const wxString& src, wxString& ldest, wxString& rdest ); +extern int FastFormatString_AsciiRaw(wxCharBuffer& dest, const char* fmt, va_list argptr); extern wxString FastFormatString_Ascii(const char* fmt, va_list argptr); extern wxString FastFormatString_Unicode(const wxChar* fmt, va_list argptr); diff --git a/common/src/Utilities/FastFormatString.cpp b/common/src/Utilities/FastFormatString.cpp index d39229be11..4c3f7b49b3 100644 --- a/common/src/Utilities/FastFormatString.cpp +++ b/common/src/Utilities/FastFormatString.cpp @@ -120,6 +120,34 @@ static void format_that_unicode_mess( SafeArray& buffer, const wxChar* f // though it'd be kinda nice if we did. } +// returns the length of the string (not including the 0) +int FastFormatString_AsciiRaw(wxCharBuffer& dest, const char* fmt, va_list argptr) +{ + if( ascii_buffer_is_deleted ) + { + // This means that the program is shutting down and the C++ destructors are + // running, randomly deallocating static variables from existence. We handle it + // as gracefully as possible by allocating local vars to do our bidding (slow, but + // ultimately necessary!) + + SafeArray localbuf( 4096, L"Temporary Ascii Formatting Buffer" ); + format_that_ascii_mess( localbuf, fmt, argptr ); + dest = localbuf.GetPtr(); + return strlen(dest); + } + else + { + // This is normal operation. The static buffers are available for use, and we use + // them for sake of efficiency (fewer heap allocs, for sure!) + + ScopedLock locker( ascii_buffer ); + format_that_ascii_mess( ascii_buffer.buffer, fmt, argptr ); + dest = ascii_buffer.buffer.GetPtr(); + return strlen(dest); + } + +} + wxString FastFormatString_Ascii(const char* fmt, va_list argptr) { if( ascii_buffer_is_deleted ) diff --git a/pcsx2/Utilities/FileUtils.cpp b/pcsx2/Utilities/FileUtils.cpp index 88b24a0e45..d3ed8b932c 100644 --- a/pcsx2/Utilities/FileUtils.cpp +++ b/pcsx2/Utilities/FileUtils.cpp @@ -20,7 +20,8 @@ void AsciiFile::Printf( const char* fmt, ... ) { va_list list; va_start( list, fmt ); - std::string writeme; vssprintf( writeme, fmt, list ); + //std::string writeme; vssprintf( writeme, fmt, list ); + wxCharBuffer result; int reslen = FastFormatString_AsciiRaw(result, fmt, list); va_end( list ); - Write( writeme.c_str(), writeme.length() ); + Write( result.data(), reslen ); } diff --git a/pcsx2/gui/AppInit.cpp b/pcsx2/gui/AppInit.cpp index f6588d9d2a..ca62b7f3b7 100644 --- a/pcsx2/gui/AppInit.cpp +++ b/pcsx2/gui/AppInit.cpp @@ -46,7 +46,7 @@ static void CpuCheckSSE2() L"Your options will be limited and emulation will be *very* slow." ) ); - pxIssueConfirmation( exconf, MsgButtons().OK(), L"Error:Startup:NoSSE2" ); + pxIssueConfirmation( exconf, MsgButtons().OK(), L"Error.Startup.NoSSE2" ); // Auto-disable anything that needs SSE2: diff --git a/pcsx2/gui/Dialogs/SysConfigDialog.cpp b/pcsx2/gui/Dialogs/SysConfigDialog.cpp index 94486539d2..287fb89b5d 100644 --- a/pcsx2/gui/Dialogs/SysConfigDialog.cpp +++ b/pcsx2/gui/Dialogs/SysConfigDialog.cpp @@ -41,7 +41,7 @@ static void CheckHacksOverrides() // [TODO] : List command line option overrides in action? - pxIssueConfirmation( dialog, MsgButtons().OK(), L"Dialog:SysConfig:Overrides" ); + pxIssueConfirmation( dialog, MsgButtons().OK(), L"Dialog.SysConfig.Overrides" ); } static void CheckPluginsOverrides() @@ -61,7 +61,7 @@ static void CheckPluginsOverrides() // [TODO] : List command line option overrides in action? - pxIssueConfirmation( dialog, MsgButtons().OK(), L"Dialog:ComponentsConfig:Overrides" ); + pxIssueConfirmation( dialog, MsgButtons().OK(), L"Dialog.ComponentsConfig.Overrides" ); } Dialogs::SysConfigDialog::SysConfigDialog(wxWindow* parent) diff --git a/pcsx2/gui/IsoDropTarget.cpp b/pcsx2/gui/IsoDropTarget.cpp index c4f3092ab9..1b320da4a6 100644 --- a/pcsx2/gui/IsoDropTarget.cpp +++ b/pcsx2/gui/IsoDropTarget.cpp @@ -75,7 +75,7 @@ bool IsoDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filen dialog += dialog.GetCharHeight(); dialog += dialog.Heading(GetMsg_ConfirmSysReset()); - confirmed = (pxIssueConfirmation( dialog, MsgButtons().Reset().Cancel(), L"DragDrop:BootELF" ) != wxID_CANCEL); + confirmed = (pxIssueConfirmation( dialog, MsgButtons().Reset().Cancel(), L"DragDrop.BootELF" ) != wxID_CANCEL); } if( confirmed ) diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index b1cea54c84..37890b7e4d 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -141,7 +141,7 @@ wxWindowID SwapOrReset_Iso( wxWindow* owner, IScopedCoreThread& core_control, co dialog += dialog.GetCharHeight(); dialog += dialog.Heading(_("Do you want to swap discs or boot the new image (via system reset)?")); - result = pxIssueConfirmation( dialog, MsgButtons().Reset().Cancel().Custom(_("Swap Disc")), L"DragDrop:BootSwapIso" ); + result = pxIssueConfirmation( dialog, MsgButtons().Reset().Cancel().Custom(_("Swap Disc")), L"DragDrop.BootSwapIso" ); if( result == wxID_CANCEL ) { core_control.AllowResume(); @@ -184,7 +184,7 @@ wxWindowID SwapOrReset_CdvdSrc( wxWindow* owner, CDVD_SourceType newsrc ) _("Do you want to swap discs or boot the new image (system reset)?") ); - result = pxIssueConfirmation( dialog, MsgButtons().Reset().Cancel().Custom(_("Swap Disc")), L"DragDrop:BootSwapIso" ); + result = pxIssueConfirmation( dialog, MsgButtons().Reset().Cancel().Custom(_("Swap Disc")), L"DragDrop.BootSwapIso" ); if( result == wxID_CANCEL ) { @@ -331,7 +331,7 @@ void MainEmuFrame::_DoBootCdvd() { wxDialogWithHelpers dialog( this, _("Confirm PS2 Reset") ); dialog += dialog.Heading( GetMsg_ConfirmSysReset() ); - bool confirmed = (pxIssueConfirmation( dialog, MsgButtons().Yes().Cancel(), L"BootCdvd:ConfirmReset" ) != wxID_CANCEL); + bool confirmed = (pxIssueConfirmation( dialog, MsgButtons().Yes().Cancel(), L"BootCdvd.ConfirmReset" ) != wxID_CANCEL); if( !confirmed ) { diff --git a/pcsx2/gui/Panels/PluginSelectorPanel.cpp b/pcsx2/gui/Panels/PluginSelectorPanel.cpp index 81775d6fd3..30ea0d5189 100644 --- a/pcsx2/gui/Panels/PluginSelectorPanel.cpp +++ b/pcsx2/gui/Panels/PluginSelectorPanel.cpp @@ -238,7 +238,7 @@ void ApplyOverValidStateEvent::InvokeEvent() L"Are you sure you want to apply settings now?" ) ); - int result = pxIssueConfirmation( dialog, MsgButtons().OK().Cancel(), L"PluginSelector:ConfirmShutdown" ); + int result = pxIssueConfirmation( dialog, MsgButtons().OK().Cancel(), L"PluginSelector.ConfirmShutdown" ); if( result == wxID_CANCEL ) throw Exception::CannotApplySettings( m_owner->GetApplicableConfigPanel() ).Quiet()