diff --git a/Common/Serialize/Serializer.h b/Common/Serialize/Serializer.h index ba8f753c83..5c1f813199 100644 --- a/Common/Serialize/Serializer.h +++ b/Common/Serialize/Serializer.h @@ -220,7 +220,9 @@ public: *savedSize = measuredSize; return ERROR_NONE; } else { - free(data); + if (!*saved) { + free(data); + } return ERROR_BROKEN_STATE; } } diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index a8fc0dae14..54a6a4355b 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -120,7 +120,12 @@ namespace SaveState CChunkFileReader::Error Save() { - rewindLastTime = time_now_d(); + rewindLastTime_ = time_now_d(); + + // Make sure we're not processing a previous save. That'll cause a hitch though, but at least won't + // crash due to contention over buffer_. + if (compressThread_.joinable()) + compressThread_.join(); std::lock_guard guard(lock_); @@ -166,7 +171,7 @@ namespace SaveState static std::vector buffer; LockedDecompress(buffer, states_[n], bases_[baseMapping_[n]]); CChunkFileReader::Error error = LoadFromRam(buffer, errorString); - rewindLastTime = time_now_d(); + rewindLastTime_ = time_now_d(); return error; } @@ -257,7 +262,7 @@ namespace SaveState buffer_.clear(); base_ = -1; baseUsage_ = 0; - rewindLastTime = time_now_d(); + rewindLastTime_ = time_now_d(); } bool Empty() const @@ -272,7 +277,7 @@ namespace SaveState // For fast-forwarding, otherwise they may be useless and too close. double now = time_now_d(); - double diff = now - rewindLastTime; + double diff = now - rewindLastTime_; if (diff < g_Config.iRewindSnapshotInterval) return; @@ -282,7 +287,7 @@ namespace SaveState void NotifyState() { // Prevent saving snapshots immediately after loading or saving a state. - rewindLastTime = time_now_d(); + rewindLastTime_ = time_now_d(); } private: @@ -307,7 +312,7 @@ namespace SaveState int base_ = -1; int baseUsage_ = 0; - double rewindLastTime = 0.0f; + double rewindLastTime_ = 0.0f; }; static bool needsProcess = false; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index c3a17ce7e9..9e4bb43a6f 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1054,7 +1054,7 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) { return UI::EVENT_CONTINUE; }); lockedMhz->SetZeroLabel(sy->T("Auto")); - PopupSliderChoice *rewindInterval = systemSettings->Add(new PopupSliderChoice(&g_Config.iRewindSnapshotInterval, 0, 30, sy->T("Rewind Snapshot Interval"), screenManager(), sy->T("seconds, 0:off"))); + PopupSliderChoice *rewindInterval = systemSettings->Add(new PopupSliderChoice(&g_Config.iRewindSnapshotInterval, 0, 60, sy->T("Rewind Snapshot Interval"), screenManager(), sy->T("seconds, 0:off"))); rewindInterval->SetZeroLabel(sy->T("Off")); systemSettings->Add(new ItemHeader(sy->T("General")));