File pcsx2_issue4294.patch of Package pcsx2-git
From 9a3ffc65d66ba514dd32ff2219f81467fc21679e Mon Sep 17 00:00:00 2001
From: Guo Yunhe <i@guoyunhe.me>
Date: Mon, 15 Mar 2021 21:24:11 +0800
Subject: [PATCH] Fix #4294 convert wxString to std::string for fmt::format()
---
pcsx2/GameDatabase.cpp | 4 ++--
pcsx2/Recording/InputRecording.cpp | 10 +++++-----
pcsx2/gui/AppCoreThread.cpp | 4 ++--
pcsx2/gui/MainFrame.cpp | 4 ++--
pcsx2/gui/Panels/GSWindowPanel.cpp | 2 +-
pcsx2/gui/Panels/VideoPanel.cpp | 8 ++++----
6 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/pcsx2/GameDatabase.cpp b/pcsx2/GameDatabase.cpp
index c064108ee1f..07994b9f2d6 100644
--- a/pcsx2/GameDatabase.cpp
+++ b/pcsx2/GameDatabase.cpp
@@ -103,7 +103,7 @@ GameDatabaseSchema::GameEntry YamlGameDatabaseImpl::entryFromYaml(const std::str
bool fixValidated = false;
for (GamefixId id = GamefixId_FIRST; id < pxEnumEnd; id++)
{
- std::string validFix = fmt::format("{}Hack", wxString(EnumToString(id)));
+ std::string validFix = fmt::format("{}Hack", wxString(EnumToString(id)).mb_str());
if (validFix == fix)
{
fixValidated = true;
@@ -129,7 +129,7 @@ GameDatabaseSchema::GameEntry YamlGameDatabaseImpl::entryFromYaml(const std::str
bool speedHackValidated = false;
for (SpeedhackId id = SpeedhackId_FIRST; id < pxEnumEnd; id++)
{
- std::string validSpeedHack = fmt::format("{}SpeedHack", wxString(EnumToString(id)));
+ std::string validSpeedHack = fmt::format("{}SpeedHack", wxString(EnumToString(id)).mb_str());
if (validSpeedHack == speedHack)
{
speedHackValidated = true;
diff --git a/pcsx2/Recording/InputRecording.cpp b/pcsx2/Recording/InputRecording.cpp
index 88a47455987..cb688ee9e9d 100644
--- a/pcsx2/Recording/InputRecording.cpp
+++ b/pcsx2/Recording/InputRecording.cpp
@@ -315,7 +315,7 @@ void InputRecording::SetupInitialState(u32 newStartingFrame)
void InputRecording::FailedSavestate()
{
- inputRec::consoleLog(fmt::format("{} is not compatible with this version of PCSX2", savestate));
+ inputRec::consoleLog(fmt::format("{} is not compatible with this version of PCSX2", savestate.mb_str()));
inputRec::consoleLog(fmt::format("Original PCSX2 version used: {}", inputRecordingData.GetHeader().emu));
inputRecordingData.Close();
initialLoad = false;
@@ -386,14 +386,14 @@ bool InputRecording::Play(wxWindow* parent, wxString filename)
L"Savestate files (*.p2s)|*.p2s", wxFD_OPEN);
if (loadStateDialog.ShowModal() == wxID_CANCEL)
{
- inputRec::consoleLog(fmt::format("Could not locate savestate file at location - {}", savestate));
+ inputRec::consoleLog(fmt::format("Could not locate savestate file at location - {}", savestate.mb_str()));
inputRec::log("Savestate load failed");
inputRecordingData.Close();
return false;
}
savestate = loadStateDialog.GetPath();
- inputRec::consoleLog(fmt::format("Base savestate set to {}", savestate));
+ inputRec::consoleLog(fmt::format("Base savestate set to {}", savestate.mb_str()));
}
state = InputRecordingMode::Replaying;
initialLoad = true;
@@ -419,7 +419,7 @@ void InputRecording::GoToFirstFrame(wxWindow* parent)
if (!initiallyPaused)
g_InputRecordingControls.PauseImmediately();
- inputRec::consoleLog(fmt::format("Could not locate savestate file at location - {}\n", savestate));
+ inputRec::consoleLog(fmt::format("Could not locate savestate file at location - {}\n", savestate.mb_str()));
wxFileDialog loadStateDialog(parent, _("Select a savestate to accompany the recording with"), L"", L"",
L"Savestate files (*.p2s)|*.p2s", wxFD_OPEN);
int result = loadStateDialog.ShowModal();
@@ -432,7 +432,7 @@ void InputRecording::GoToFirstFrame(wxWindow* parent)
return;
}
savestate = loadStateDialog.GetPath();
- inputRec::consoleLog(fmt::format ("Base savestate swapped to {}", savestate));
+ inputRec::consoleLog(fmt::format ("Base savestate swapped to {}", savestate.mb_str()));
}
StateCopy_LoadFromFile(savestate);
}
diff --git a/pcsx2/gui/AppCoreThread.cpp b/pcsx2/gui/AppCoreThread.cpp
index a5950a0b7dc..b29754bf1be 100644
--- a/pcsx2/gui/AppCoreThread.cpp
+++ b/pcsx2/gui/AppCoreThread.cpp
@@ -309,7 +309,7 @@ static int loadGameSettings(Pcsx2Config& dest, const GameDatabaseSchema::GameEnt
// TODO - config - this could be simplified with maps instead of bitfields and enums
for (SpeedhackId id = SpeedhackId_FIRST; id < pxEnumEnd; id++)
{
- std::string key = fmt::format("{}SpeedHack", wxString(EnumToString(id)));
+ std::string key = fmt::format("{}SpeedHack", wxString(EnumToString(id)).mb_str());
// Gamefixes are already guaranteed to be valid, any invalid ones are dropped
if (game.speedHacks.count(key) == 1)
@@ -326,7 +326,7 @@ static int loadGameSettings(Pcsx2Config& dest, const GameDatabaseSchema::GameEnt
// TODO - config - this could be simplified with maps instead of bitfields and enums
for (GamefixId id = GamefixId_FIRST; id < pxEnumEnd; id++)
{
- std::string key = fmt::format("{}Hack", wxString(EnumToString(id)));
+ std::string key = fmt::format("{}Hack", wxString(EnumToString(id)).mb_str());
// Gamefixes are already guaranteed to be valid, any invalid ones are dropped
if (std::find(game.gameFixes.begin(), game.gameFixes.end(), key) != game.gameFixes.end())
diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp
index 16d128aa337..120251b9b68 100644
--- a/pcsx2/gui/MainFrame.cpp
+++ b/pcsx2/gui/MainFrame.cpp
@@ -58,9 +58,9 @@ wxMenu* MainEmuFrame::MakeStatesSubMenu(int baseid, int loadBackupId) const
// For safety i also made them inactive aka grayed out to signify that's it's only for informational purposes
// Fixme: In the future this can still be expanded to actually cycle savestates in the GUI.
mnuSubstates->Append(baseid - 1, _("File..."));
- wxMenuItem* CycleNext = mnuSubstates->Append(baseid - 2, _("Cycle to next slot") + wxString(" ") + fmt::format("({})", wxGetApp().GlobalAccels->findKeycodeWithCommandId("States_CycleSlotForward").toTitleizedString()));
+ wxMenuItem* CycleNext = mnuSubstates->Append(baseid - 2, _("Cycle to next slot") + wxString(" ") + fmt::format("({})", wxGetApp().GlobalAccels->findKeycodeWithCommandId("States_CycleSlotForward").toTitleizedString().mb_str()));
CycleNext->Enable(false);
- wxMenuItem* CycleBack = mnuSubstates->Append(baseid - 3, _("Cycle to previous slot") + wxString(" ") + fmt::format("({})", wxGetApp().GlobalAccels->findKeycodeWithCommandId("States_CycleSlotBackward").toTitleizedString()));
+ wxMenuItem* CycleBack = mnuSubstates->Append(baseid - 3, _("Cycle to previous slot") + wxString(" ") + fmt::format("({})", wxGetApp().GlobalAccels->findKeycodeWithCommandId("States_CycleSlotBackward").toTitleizedString().mb_str()));
CycleBack->Enable(false);
return mnuSubstates;
}
diff --git a/pcsx2/gui/Panels/GSWindowPanel.cpp b/pcsx2/gui/Panels/GSWindowPanel.cpp
index 46af4a40fc3..14b3b9102ad 100644
--- a/pcsx2/gui/Panels/GSWindowPanel.cpp
+++ b/pcsx2/gui/Panels/GSWindowPanel.cpp
@@ -107,7 +107,7 @@ Panels::GSWindowSettingsPanel::GSWindowSettingsPanel(wxWindow* parent)
s_AspectRatio.AddGrowableCol(1);
// Implement custom hotkeys (F6) with translatable string intact + not blank in GUI.
- s_AspectRatio += Label(_("Aspect Ratio:") + wxString(" ") + fmt::format("({})", wxGetApp().GlobalAccels->findKeycodeWithCommandId("GSwindow_CycleAspectRatio").toTitleizedString())) | pxMiddle;
+ s_AspectRatio += Label(_("Aspect Ratio:") + wxString(" ") + fmt::format("({})", wxGetApp().GlobalAccels->findKeycodeWithCommandId("GSwindow_CycleAspectRatio").toTitleizedString().mb_str())) | pxMiddle;
s_AspectRatio += m_combo_AspectRatio | pxAlignRight;
s_AspectRatio += Label(_("FMV Aspect Ratio Override:")) | pxMiddle;
s_AspectRatio += m_combo_FMVAspectRatioSwitch | pxAlignRight;
diff --git a/pcsx2/gui/Panels/VideoPanel.cpp b/pcsx2/gui/Panels/VideoPanel.cpp
index 616d55c96f9..035f3194000 100644
--- a/pcsx2/gui/Panels/VideoPanel.cpp
+++ b/pcsx2/gui/Panels/VideoPanel.cpp
@@ -65,7 +65,7 @@ Panels::FramelimiterPanel::FramelimiterPanel( wxWindow* parent )
// Implement custom hotkeys (Shift + Tab) with translatable string intact + not blank in GUI.
- s_spins += Label(_("Slow Motion Adjust:") + wxString(" ") + fmt::format("({})", wxGetApp().GlobalAccels->findKeycodeWithCommandId("Framelimiter_SlomoToggle").toTitleizedString())) | StdExpand();
+ s_spins += Label(_("Slow Motion Adjust:") + wxString(" ") + fmt::format("({})", wxGetApp().GlobalAccels->findKeycodeWithCommandId("Framelimiter_SlomoToggle").toTitleizedString().mb_str())) | StdExpand();
s_spins += 5;
s_spins += m_spin_SlomoPct | pxBorder(wxTOP, 3);
s_spins += Label(L"%") | StdExpand();
@@ -73,7 +73,7 @@ Panels::FramelimiterPanel::FramelimiterPanel( wxWindow* parent )
// Implement custom hotkeys (Tab) with translatable string intact + not blank in GUI.
- s_spins += Label(_("Turbo Adjust:") + wxString(" ") + fmt::format("({})", wxGetApp().GlobalAccels->findKeycodeWithCommandId("Framelimiter_TurboToggle").toTitleizedString())) | StdExpand();
+ s_spins += Label(_("Turbo Adjust:") + wxString(" ") + fmt::format("({})", wxGetApp().GlobalAccels->findKeycodeWithCommandId("Framelimiter_TurboToggle").toTitleizedString().mb_str())) | StdExpand();
s_spins += 5;
s_spins += m_spin_TurboPct | pxBorder(wxTOP, 3);
s_spins += Label(L"%") | StdExpand();
@@ -184,11 +184,11 @@ Panels::FrameSkipPanel::FrameSkipPanel( wxWindow* parent )
),
// Implement custom hotkeys (Tab) with translatable string intact + not blank in GUI.
RadioPanelItem(
- _("Skip only on Turbo, to enable press") + fmt::format("{} ({})", " ", wxGetApp().GlobalAccels->findKeycodeWithCommandId("Framelimiter_TurboToggle").toTitleizedString())
+ _("Skip only on Turbo, to enable press") + fmt::format("{} ({})", " ", wxGetApp().GlobalAccels->findKeycodeWithCommandId("Framelimiter_TurboToggle").toTitleizedString().mb_str())
),
// Implement custom hotkeys (Shift + F4) with translatable string intact + not blank in GUI.
RadioPanelItem(
- _("Constant skipping") + fmt::format("{} ({})", " ", wxGetApp().GlobalAccels->findKeycodeWithCommandId("Frameskip_Toggle").toTitleizedString()),
+ _("Constant skipping") + fmt::format("{} ({})", " ", wxGetApp().GlobalAccels->findKeycodeWithCommandId("Frameskip_Toggle").toTitleizedString().mb_str()),
wxEmptyString,
_("Normal and Turbo limit rates skip frames. Slow motion mode will still disable frameskipping.")
),