diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index ca8bf079b..0827c859d 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -6535,7 +6535,7 @@ void FullscreenUI::DoSaveState(s32 slot, bool global) std::string filename(global ? System::GetGlobalSaveStateFileName(slot) : System::GetGameSaveStateFileName(System::GetGameSerial(), slot)); Error error; - if (!System::SaveState(filename.c_str(), &error, g_settings.create_save_state_backups)) + if (!System::SaveState(filename.c_str(), &error, g_settings.create_save_state_backups, false)) { ShowToast(std::string(), fmt::format(TRANSLATE_FS("System", "Failed to save state: {}"), error.GetDescription())); } diff --git a/src/core/hotkeys.cpp b/src/core/hotkeys.cpp index 15b3bbaef..53cff0902 100644 --- a/src/core/hotkeys.cpp +++ b/src/core/hotkeys.cpp @@ -111,7 +111,7 @@ static void HotkeySaveStateSlot(bool global, s32 slot) std::string path(global ? System::GetGlobalSaveStateFileName(slot) : System::GetGameSaveStateFileName(System::GetGameSerial(), slot)); Error error; - if (!System::SaveState(path.c_str(), &error, g_settings.create_save_state_backups)) + if (!System::SaveState(path.c_str(), &error, g_settings.create_save_state_backups, false)) { Host::AddIconOSDMessage( "SaveState", ICON_FA_EXCLAMATION_TRIANGLE, diff --git a/src/core/imgui_overlays.cpp b/src/core/imgui_overlays.cpp index afd09ec3b..c246ed696 100644 --- a/src/core/imgui_overlays.cpp +++ b/src/core/imgui_overlays.cpp @@ -1277,7 +1277,7 @@ void SaveStateSelectorUI::SaveCurrentSlot() if (std::string path = GetCurrentSlotPath(); !path.empty()) { Error error; - if (!System::SaveState(path.c_str(), &error, g_settings.create_save_state_backups)) + if (!System::SaveState(path.c_str(), &error, g_settings.create_save_state_backups, false)) { Host::AddIconOSDMessage("SaveState", ICON_EMOJI_WARNING, fmt::format(TRANSLATE_FS("OSDMessage", "Failed to save state to slot {0}:\n{1}"), diff --git a/src/core/system.cpp b/src/core/system.cpp index a6e9e1184..bad57f340 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -1664,7 +1664,7 @@ bool System::SaveResumeState(Error* error) } const std::string path(GetGameSaveStateFileName(s_state.running_game_serial, -1)); - return SaveState(path.c_str(), error, false); + return SaveState(path.c_str(), error, false, true); } bool System::BootSystem(SystemBootParameters parameters, Error* error) @@ -3010,14 +3010,14 @@ bool System::ReadAndDecompressStateData(std::FILE* fp, std::span dst, u32 fi } } -bool System::SaveState(const char* path, Error* error, bool backup_existing_save) +bool System::SaveState(const char* path, Error* error, bool backup_existing_save, bool ignore_memcard_busy) { if (!IsValid() || IsReplayingGPUDump()) { Error::SetStringView(error, TRANSLATE_SV("System", "System is not in correct state.")); return false; } - else if (IsSavingMemoryCards()) + else if (!ignore_memcard_busy && IsSavingMemoryCards()) { Error::SetStringView(error, TRANSLATE_SV("System", "Cannot save state while memory card is being saved.")); return false; diff --git a/src/core/system.h b/src/core/system.h index c61a715c2..33c544bdf 100644 --- a/src/core/system.h +++ b/src/core/system.h @@ -256,7 +256,7 @@ void ResetSystem(); /// Loads state from the specified path. bool LoadState(const char* path, Error* error, bool save_undo_state); -bool SaveState(const char* path, Error* error, bool backup_existing_save); +bool SaveState(const char* path, Error* error, bool backup_existing_save, bool ignore_memcard_busy); bool SaveResumeState(Error* error); /// Runs the VM until the CPU execution is canceled. diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp index 129531853..4d73b8abe 100644 --- a/src/duckstation-qt/qthost.cpp +++ b/src/duckstation-qt/qthost.cpp @@ -1412,7 +1412,7 @@ void EmuThread::saveState(const QString& filename, bool block_until_done /* = fa return; Error error; - if (!System::SaveState(filename.toUtf8().data(), &error, g_settings.create_save_state_backups)) + if (!System::SaveState(filename.toUtf8().data(), &error, g_settings.create_save_state_backups, false)) emit errorReported(tr("Error"), tr("Failed to save state: %1").arg(QString::fromStdString(error.GetDescription()))); } @@ -1432,7 +1432,7 @@ void EmuThread::saveState(bool global, qint32 slot, bool block_until_done /* = f if (!System::SaveState((global ? System::GetGlobalSaveStateFileName(slot) : System::GetGameSaveStateFileName(System::GetGameSerial(), slot)) .c_str(), - &error, g_settings.create_save_state_backups)) + &error, g_settings.create_save_state_backups, false)) { emit errorReported(tr("Error"), tr("Failed to save state: %1").arg(QString::fromStdString(error.GetDescription()))); }