From 32fbcaffd2813cd135fa913c51c18d25fc20681c Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 15 May 2022 16:28:37 +1000 Subject: [PATCH] [client] spice: fix spice shutdown race Fixes #960 --- client/src/main.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/client/src/main.c b/client/src/main.c index d931eab9..1db1d7b1 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -920,6 +920,19 @@ int spiceThread(void * arg) } } + // send key up events for any pressed keys + if (g_params.useSpiceInput) + { + for(int scancode = 0; scancode < KEY_MAX; ++scancode) + if (g_state.keyDown[scancode]) + { + g_state.keyDown[scancode] = false; + purespice_keyUp(scancode); + } + } + + purespice_disconnect(); + end: audio_free(); @@ -1540,6 +1553,10 @@ restart: static void lg_shutdown(void) { g_state.state = APP_STATE_SHUTDOWN; + + if (t_spice) + lgJoinThread(t_spice, NULL); + if (t_render) { if (g_state.jitRender && g_state.ds->stopWaitFrame) @@ -1563,21 +1580,6 @@ static void lg_shutdown(void) e_startup = NULL; } - // if spice is still connected send key up events for any pressed keys - if (g_params.useSpiceInput) - { - for(int scancode = 0; scancode < KEY_MAX; ++scancode) - if (g_state.keyDown[scancode]) - { - g_state.keyDown[scancode] = false; - purespice_keyUp(scancode); - } - - purespice_disconnect(); - if (t_spice) - lgJoinThread(t_spice, NULL); - } - if (g_state.ds) g_state.ds->shutdown();