Changed the way the emulator is shut down, fixes #1555.
This commit is contained in:
@@ -69,6 +69,7 @@ HANDLE ghMutex;
|
||||
LCID lang_id; /* current language ID used */
|
||||
DWORD dwSubLangID;
|
||||
int acp_utf8; /* Windows supports UTF-8 codepage */
|
||||
volatile int cpu_thread_run = 1;
|
||||
|
||||
|
||||
/* Local data. */
|
||||
@@ -487,7 +488,7 @@ main_thread(void *param)
|
||||
title_update = 1;
|
||||
old_time = GetTickCount();
|
||||
drawits = frames = 0;
|
||||
while (!is_quit) {
|
||||
while (!is_quit && cpu_thread_run) {
|
||||
/* See if it is time to run a frame of code. */
|
||||
new_time = GetTickCount();
|
||||
drawits += (new_time - old_time);
|
||||
@@ -511,7 +512,7 @@ main_thread(void *param)
|
||||
Sleep(1);
|
||||
|
||||
/* If needed, handle a screen resize. */
|
||||
if (doresize && !video_fullscreen) {
|
||||
if (doresize && !video_fullscreen && !is_quit) {
|
||||
if (vid_resize & 2)
|
||||
plat_resize(fixed_size_x, fixed_size_y);
|
||||
else
|
||||
@@ -519,6 +520,8 @@ main_thread(void *param)
|
||||
doresize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
is_quit = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -551,16 +554,17 @@ do_start(void)
|
||||
void
|
||||
do_stop(void)
|
||||
{
|
||||
is_quit = 1;
|
||||
/* Claim the video blitter. */
|
||||
startblit();
|
||||
|
||||
plat_delay_ms(100);
|
||||
|
||||
if (source_hwnd)
|
||||
PostMessage((HWND) (uintptr_t) source_hwnd, WM_HAS_SHUTDOWN, (WPARAM) 0, (LPARAM) hwndMain);
|
||||
vid_apis[vid_api].close();
|
||||
|
||||
pc_close(thMain);
|
||||
|
||||
thMain = NULL;
|
||||
|
||||
if (source_hwnd)
|
||||
PostMessage((HWND) (uintptr_t) source_hwnd, WM_HAS_SHUTDOWN, (WPARAM) 0, (LPARAM) hwndMain);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -477,9 +477,10 @@ plat_power_off(void)
|
||||
|
||||
/* Cleanly terminate all of the emulator's components so as
|
||||
to avoid things like threads getting stuck. */
|
||||
do_stop();
|
||||
// do_stop();
|
||||
cpu_thread_run = 0;
|
||||
|
||||
exit(-1);
|
||||
// exit(-1);
|
||||
}
|
||||
|
||||
#ifdef MTR_ENABLED
|
||||
@@ -1547,10 +1548,10 @@ ui_init(int nCmdShow)
|
||||
fatal("bRet is -1\n");
|
||||
}
|
||||
|
||||
if (messages.message == WM_QUIT) {
|
||||
is_quit = 1;
|
||||
break;
|
||||
}
|
||||
/* On WM_QUIT, tell the CPU thread to stop running. That will then tell us
|
||||
to stop running as well. */
|
||||
if (messages.message == WM_QUIT)
|
||||
cpu_thread_run = 0;
|
||||
|
||||
if (! TranslateAccelerator(hwnd, haccel, &messages))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user