use app->quit on main thread instead of oc_should_quit(), to ensure that runloop_thread always exits its event loop before main thread

This commit is contained in:
martinfouilleul 2023-08-30 12:06:32 +02:00
parent 1907663cdc
commit 19ce7447aa
2 changed files with 5 additions and 3 deletions

View File

@ -565,7 +565,7 @@ i32 orca_runloop(void* user)
{ {
case OC_EVENT_WINDOW_CLOSE: case OC_EVENT_WINDOW_CLOSE:
{ {
oc_request_quit(); oc_request_quit();
} }
break; break;
@ -841,6 +841,8 @@ i32 orca_runloop(void* user)
} }
} }
app->quit = true;
return (0); return (0);
} }
@ -889,7 +891,7 @@ int main(int argc, char** argv)
oc_thread* runloopThread = oc_thread_create(orca_runloop, 0); oc_thread* runloopThread = oc_thread_create(orca_runloop, 0);
while(!oc_should_quit()) while(!app->quit)
{ {
oc_pump_events(-1); oc_pump_events(-1);
//TODO: what to do with mem scratch here? //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_canvas_destroy(app->debugOverlay.canvas);
oc_surface_destroy(app->debugOverlay.surface); oc_surface_destroy(app->debugOverlay.surface);
oc_window_destroy(app->window); oc_window_destroy(app->window);
oc_terminate(); oc_terminate();

View File

@ -111,6 +111,7 @@ typedef struct oc_debug_overlay
typedef struct oc_runtime typedef struct oc_runtime
{ {
bool quit;
oc_window window; oc_window window;
oc_file_table fileTable; oc_file_table fileTable;