diff --git a/src/conio/sdl_con.c b/src/conio/sdl_con.c index 0690c917e2a8f231d58a53ba4d09c394d54da5ca..06b18d17b43672d7911fbfa68d1b89a189bf16b2 100644 --- a/src/conio/sdl_con.c +++ b/src/conio/sdl_con.c @@ -82,6 +82,7 @@ struct sdl_keyvals { static pthread_mutex_t sdl_headlock; static struct rectlist *update_list = NULL; static struct rectlist *update_list_tail = NULL; +extern int sdl_video_initialized; #ifdef __DARWIN__ static int mac_width; @@ -1150,6 +1151,7 @@ void sdl_video_event_thread(void *data) sdl_add_key(CIO_KEY_QUIT, &cvstat); else { sdl.QuitSubSystem(SDL_INIT_VIDEO); + sdl_video_initialized = FALSE; return; } break; @@ -1188,6 +1190,7 @@ void sdl_video_event_thread(void *data) case SDL_USEREVENT_QUIT: sdl_ufunc_retval=0; sdl.QuitSubSystem(SDL_INIT_VIDEO); + sdl_video_initialized = FALSE; sem_post(&sdl_ufunc_ret); return; case SDL_USEREVENT_FLUSH: diff --git a/src/syncterm/syncterm.c b/src/syncterm/syncterm.c index 6e535dccb943e41042e1f058e8835629e57dd2da..160ee148adc8967534a15866dc710ee3133211a6 100644 --- a/src/syncterm/syncterm.c +++ b/src/syncterm/syncterm.c @@ -2581,6 +2581,9 @@ ciolib_to_screen(int ciolib) } #if defined(_WIN32) && defined(DLLIFY) +#ifdef WITH_SDL +extern int sdl_video_initialized; +#endif __declspec(dllexport) int __cdecl stub_main(int argc, char *argv[], char **env) { int n; @@ -2611,6 +2614,10 @@ __declspec(dllexport) int __cdecl stub_main(int argc, char *argv[], char **env) /* Run the application main() code */ n=CIOLIB_main(argc, argv); +#ifdef WITH_SDL + // Defeat the QuitWrap call to uninitialize SDL. + sdl_video_initialized = FALSE; +#endif /* Exit cleanly, calling atexit() functions */ exit(n);