Commit db01d4e6ca19f046d71b28c0ad3215249ec5b9ad

Thomas de Grivel 2022-08-10T15:17:15

fix race condition

diff --git a/lib/glfw3/keyboard.c b/lib/glfw3/keyboard.c
index 2ebe151..c171488 100644
--- a/lib/glfw3/keyboard.c
+++ b/lib/glfw3/keyboard.c
@@ -239,8 +239,8 @@ void rtbuf_glfw3_keyboard_close (GLFWwindow *window)
   s_rtbuf *rtb = (s_rtbuf*) glfwGetWindowUserPointer(window);
   s_rtbuf_glfw3_keyboard_data* data = (s_rtbuf_glfw3_keyboard_data*)
     rtb->data;
-  glfwDestroyWindow(window);
   data->window = 0;
+  glfwDestroyWindow(window);
 }
 
 GLFWwindow * rtbuf_glfw3_keyboard_window (s_rtbuf *rtb)
@@ -295,6 +295,7 @@ int rtbuf_glfw3_keyboard_stop (s_rtbuf *rtb)
   s_rtbuf_glfw3_keyboard_data *data;
   data = (s_rtbuf_glfw3_keyboard_data*) rtb->data;
   rtbuf_music_notes_delete_all(&data->notes);
+  rtbuf_glfw3_keyboard_close(data->window);
   return 0;
 }