Clear out state before deserialization - fixes many crashes.

This commit is contained in:
Hamish Milne 2020-04-01 22:06:22 +01:00
parent f156fdd332
commit 5b6ee9a6ab
5 changed files with 24 additions and 9 deletions

View file

@ -8,6 +8,7 @@
#include "common/logging/log.h"
#include "common/scm_rev.h"
#include "common/zstd_compression.h"
#include "core/cheats/cheats.h"
#include "core/core.h"
#include "core/savestate.h"
#include "video_core/video_core.h"
@ -158,6 +159,15 @@ void System::LoadState(u32 slot) {
std::ios_base::binary};
decompressed.clear();
// When loading, we want to make sure any lingering state gets cleared out before we begin.
// Shutdown, but persist a few things between loads...
Shutdown(true);
// Re-initialize everything like it was before
auto system_mode = this->app_loader->LoadKernelSystemMode();
auto n3ds_mode = this->app_loader->LoadKernelN3dsMode();
Init(*m_emu_window, *system_mode.first, *n3ds_mode.first);
try {
{