From b7e3e83f3eff5328f3ea3d28ba2f32145f1dc72f Mon Sep 17 00:00:00 2001 From: Martin Fouilleul Date: Mon, 26 Jun 2023 20:00:29 +0200 Subject: [PATCH] Block for events in main thread, and avoid burning the planet --- milepost | 2 +- src/main.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/milepost b/milepost index ffb900d..21aa1be 160000 --- a/milepost +++ b/milepost @@ -1 +1 @@ -Subproject commit ffb900d872a456cc5e7cc1762b1846c0c4df08cd +Subproject commit 21aa1bef68c3590c1898a539da4c38e3854a5a9d diff --git a/src/main.c b/src/main.c index 82ab5f0..e236f53 100644 --- a/src/main.c +++ b/src/main.c @@ -767,7 +767,7 @@ int main(int argc, char** argv) //WARN: this is a workaround to avoid stalling the first few times we acquire drawables from // the surfaces... This should probably be fixed in the implementation of mtl_surface! -//* + for(int i=0; i<3; i++) { mg_surface_prepare(app->surface); @@ -780,7 +780,7 @@ int main(int argc, char** argv) mg_render(app->debugOverlay.surface, app->debugOverlay.canvas); mg_surface_present(app->debugOverlay.surface); } -//*/ + ui_init(&app->debugOverlay.ui); //NOTE: show window and start runloop @@ -793,15 +793,19 @@ int main(int argc, char** argv) while(!mp_should_quit()) { - mp_pump_events(0); + mp_pump_events(-1); //TODO: what to do with mem scratch here? } void* res; pthread_join(runloopThread, &res); -// mg_canvas_destroy(app->canvas); -// mg_surface_destroy(app->surface); + mg_canvas_destroy(app->canvas); + mg_surface_destroy(app->surface); + + mg_canvas_destroy(app->debugOverlay.canvas); + mg_surface_destroy(app->debugOverlay.surface); + mp_window_destroy(app->window); mp_terminate();