Skip to content
Snippets Groups Projects
Commit 58079666 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Fix "ghost" instance of SyncTERM on exit in SDL mode on Win32

Since nothing will default to this mode anymore, we can just hack
this fix into SyncTERM. This ensures that if SyncTERM is terminated
by calling return from main() on Windows that the quit wrapper does
nothing.

This is a fairly ugly hack, but it works for SyncTERM.

Fixes ticket 203
parent 26d7130e
Branches
Tags
No related merge requests found
Pipeline #8889 passed
......@@ -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:
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment