Fixed save-state on exit not working if there was a VM restart (eg. config h/w change). Fixes #564

This commit is contained in:
tomcw 2018-07-31 18:06:53 +01:00
parent 140d505fe9
commit 898f30f08a
2 changed files with 7 additions and 3 deletions

View File

@ -1092,6 +1092,7 @@ LRESULT CALLBACK FrameWndProc (
g_TimerIDEvent_100msec = 0;
}
LogFileOutput("WM_CLOSE (done)\n");
// Exit via DefWindowProc(), which does the default action for WM_CLOSE, which is to call DestroyWindow(), posting WM_DESTROY
break;
case WM_CHAR:
@ -1175,7 +1176,8 @@ LRESULT CALLBACK FrameWndProc (
case WM_DESTROY:
LogFileOutput("WM_DESTROY\n");
DragAcceptFiles(window,0);
Snapshot_Shutdown();
if (!g_bRestart) // GH#564: Only save-state on shutdown (not on a restart)
Snapshot_Shutdown();
DebugDestroy();
if (!g_bRestart) {
DiskDestroy();

View File

@ -637,17 +637,19 @@ void Snapshot_Startup()
Snapshot_LoadState();
bDone = true;
bDone = true; // Prevents a g_bRestart from loading an old save-state
}
void Snapshot_Shutdown()
{
static bool bDone = false;
_ASSERT(!bDone);
_ASSERT(!g_bRestart);
if(!g_bSaveStateOnExit || bDone)
return;
Snapshot_SaveState();
bDone = true;
bDone = true; // Debug flag: should only be called once, and never on a g_bRestart
}