uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 4c59498f14d0ee684ca5a69a9e3b79abf274c88a
parent 219cfee4729dabaa3fd69cf890cce519bf2005b4
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date:   Sat,  9 Apr 2022 12:22:24 +0100

(Windows) Fix uxnemu freezing on exit.

Diffstat:
Msrc/uxnemu.c | 11++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -16,6 +16,9 @@ #include "devices/controller.h" #include "devices/mouse.h" #include "devices/datetime.h" +#ifdef _WIN32 +#include <processthreadsapi.h> +#endif #pragma GCC diagnostic pop #pragma clang diagnostic pop @@ -40,6 +43,7 @@ static SDL_Texture *gTexture; static SDL_Renderer *gRenderer; static SDL_AudioDeviceID audio_id; static SDL_Rect gRect; +static SDL_Thread *stdin_thread; /* devices */ @@ -179,7 +183,7 @@ init(void) audio0_event = SDL_RegisterEvents(POLYPHONY); redraw_event = SDL_RegisterEvents(1); interrupt_event = SDL_RegisterEvents(1); - SDL_DetachThread(SDL_CreateThread(stdin_handler, "stdin", NULL)); + SDL_DetachThread(stdin_thread = SDL_CreateThread(stdin_handler, "stdin", NULL)); SDL_DetachThread(SDL_CreateThread(redraw_handler, "redraw", NULL)); SDL_StartTextInput(); SDL_ShowCursor(SDL_DISABLE); @@ -507,7 +511,12 @@ main(int argc, char **argv) if(!loaded && !start(&u, "launcher.rom")) return error("usage", "uxnemu [-s scale] file.rom"); run(&u); +#ifdef _WIN32 +#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" + TerminateThread((HANDLE)SDL_GetThreadID(stdin_thread), 0); +#else close(0); /* make stdin thread exit */ +#endif SDL_Quit(); return 0; }