From 19ce7447aa9d28efc3f2523d18719ca3d81d3b41 Mon Sep 17 00:00:00 2001 From: martinfouilleul Date: Wed, 30 Aug 2023 12:06:32 +0200 Subject: [PATCH] use app->quit on main thread instead of oc_should_quit(), to ensure that runloop_thread always exits its event loop before main thread --- src/runtime.c | 7 ++++--- src/runtime.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/runtime.c b/src/runtime.c index b851e90..9935976 100644 --- a/src/runtime.c +++ b/src/runtime.c @@ -565,7 +565,7 @@ i32 orca_runloop(void* user) { case OC_EVENT_WINDOW_CLOSE: { - oc_request_quit(); + oc_request_quit(); } break; @@ -841,6 +841,8 @@ i32 orca_runloop(void* user) } } + app->quit = true; + return (0); } @@ -889,7 +891,7 @@ int main(int argc, char** argv) oc_thread* runloopThread = oc_thread_create(orca_runloop, 0); - while(!oc_should_quit()) + while(!app->quit) { oc_pump_events(-1); //TODO: what to do with mem scratch here? @@ -899,7 +901,6 @@ int main(int argc, char** argv) oc_canvas_destroy(app->debugOverlay.canvas); oc_surface_destroy(app->debugOverlay.surface); - oc_window_destroy(app->window); oc_terminate(); diff --git a/src/runtime.h b/src/runtime.h index 7d6b4d2..271df68 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -111,6 +111,7 @@ typedef struct oc_debug_overlay typedef struct oc_runtime { + bool quit; oc_window window; oc_file_table fileTable;