Fixed crash on shutdown with -d1 arg and GPL declined (#286)

This commit is contained in:
tomcw 2015-05-03 16:35:49 +01:00
parent 60db3d6622
commit 4d61eb6a75

View File

@ -736,6 +736,7 @@ static int DoDiskInsert(const int nDrive, LPCSTR szFileName)
int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
{ {
bool bShutdown = false;
bool bSetFullScreen = false; bool bSetFullScreen = false;
bool bBoot = false; bool bBoot = false;
LPSTR szImageName_drive1 = NULL; LPSTR szImageName_drive1 = NULL;
@ -1003,7 +1004,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
if (bShowAboutDlg) if (bShowAboutDlg)
{ {
if (!AboutDlg()) if (!AboutDlg())
PostMessage(g_hFrameWindow, WM_DESTROY, 0, 0); // Close everything down bShutdown = true; // Close everything down
else else
RegSaveString(TEXT(REG_CONFIG), TEXT(REGVALUE_VERSION), 1, VERSIONSTRING); // Only save version after user accepts license RegSaveString(TEXT(REG_CONFIG), TEXT(REGVALUE_VERSION), 1, VERSIONSTRING); // Only save version after user accepts license
} }
@ -1019,13 +1020,13 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
if (!bSysClkOK) if (!bSysClkOK)
{ {
MessageBox(g_hFrameWindow, "DirectX failed to create SystemClock instance", TEXT("AppleWin Error"), MB_OK); MessageBox(g_hFrameWindow, "DirectX failed to create SystemClock instance", TEXT("AppleWin Error"), MB_OK);
PostMessage(g_hFrameWindow, WM_DESTROY, 0, 0); // Close everything down bShutdown = true;
} }
if (g_bCustomRomF8Failed) if (g_bCustomRomF8Failed)
{ {
MessageBox(g_hFrameWindow, "Failed to load custom F8 rom (not found or not exactly 2KB)", TEXT("AppleWin Error"), MB_OK); MessageBox(g_hFrameWindow, "Failed to load custom F8 rom (not found or not exactly 2KB)", TEXT("AppleWin Error"), MB_OK);
PostMessage(g_hFrameWindow, WM_DESTROY, 0, 0); // Close everything down bShutdown = true;
} }
tfe_init(); tfe_init();
@ -1034,6 +1035,13 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
Snapshot_Startup(); // Do this after everything has been init'ed Snapshot_Startup(); // Do this after everything has been init'ed
LogFileOutput("Main: Snapshot_Startup()\n"); LogFileOutput("Main: Snapshot_Startup()\n");
if (bShutdown)
{
PostMessage(g_hFrameWindow, WM_DESTROY, 0, 0); // Close everything down
// NB. If shutting down, then don't post any other messages (GH#286)
}
else
{
if (bSetFullScreen) if (bSetFullScreen)
{ {
PostMessage(g_hFrameWindow, WM_USER_FULLSCREEN, 0, 0); PostMessage(g_hFrameWindow, WM_USER_FULLSCREEN, 0, 0);
@ -1045,6 +1053,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
PostMessage(g_hFrameWindow, WM_USER_BOOT, 0, 0); PostMessage(g_hFrameWindow, WM_USER_BOOT, 0, 0);
bBoot = false; bBoot = false;
} }
}
// ENTER THE MAIN MESSAGE LOOP // ENTER THE MAIN MESSAGE LOOP
LogFileOutput("Main: EnterMessageLoop()\n"); LogFileOutput("Main: EnterMessageLoop()\n");