From 717677402cfe52ba5c045e6eec060b064818f750 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Fri, 17 Jul 2020 21:47:09 -0400 Subject: [PATCH] gui: Simplify function and solve unlikely edge-case If backups are enabled, the .backup file will have already been created via renaming the original save-state. The asynchronous process is dumping the current emulation state, but by the time we've hit this function the rename has already taken place so we have a guarantee. This solves a potential bug in the existing code (which probably would have never been hit): Save to slot that has no current backup Rename fails Update method looks for the file without .backup, which is still there. Load backup option is enabled despite there not actually being a backup to load. --- pcsx2/gui/Saveslots.cpp | 12 ++++-------- pcsx2/gui/Saveslots.h | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/pcsx2/gui/Saveslots.cpp b/pcsx2/gui/Saveslots.cpp index e1c15558d5..cb2ba86c74 100644 --- a/pcsx2/gui/Saveslots.cpp +++ b/pcsx2/gui/Saveslots.cpp @@ -71,7 +71,6 @@ void States_FreezeCurrentSlot() Console.WriteLn("Load or save action is already pending."); return; } - States_updateLoadBackupMenuItem(true); GSchangeSaveState(StatesC, SaveStateBase::GetFilename(StatesC).ToUTF8()); StateCopy_SaveToSlot(StatesC); @@ -81,6 +80,8 @@ void States_FreezeCurrentSlot() #endif GetSysExecutorThread().PostIdleEvent(SysExecEvent_ClearSavingLoadingFlag()); + + States_updateLoadBackupMenuItem(); } void _States_DefrostCurrentSlot(bool isFromBackup) @@ -115,14 +116,9 @@ void States_DefrostCurrentSlotBackup() _States_DefrostCurrentSlot(true); } -void States_updateLoadBackupMenuItem(bool isBeforeSave) +void States_updateLoadBackupMenuItem() { - wxString file = SaveStateBase::GetFilename(StatesC); - - if (!(isBeforeSave && g_Conf->EmuOptions.BackupSavestate)) - { - file = file + L".backup"; - } + wxString file = SaveStateBase::GetFilename(StatesC) + ".backup"; sMainFrame.EnableMenuItem(MenuId_State_LoadBackup, wxFileExists(file)); sMainFrame.SetMenuItemLabel(MenuId_State_LoadBackup, wxsFormat(L"%s %d", _("Backup"), StatesC)); diff --git a/pcsx2/gui/Saveslots.h b/pcsx2/gui/Saveslots.h index d5bbd8d5bf..f15bd28ec1 100644 --- a/pcsx2/gui/Saveslots.h +++ b/pcsx2/gui/Saveslots.h @@ -134,4 +134,4 @@ extern void States_CycleSlotForward(); extern void States_CycleSlotBackward(); extern void States_SetCurrentSlot(int slot); extern int States_GetCurrentSlot(); -extern void States_updateLoadBackupMenuItem(bool isBeforeSave = false); \ No newline at end of file +extern void States_updateLoadBackupMenuItem(); \ No newline at end of file