sysprof-cat: use single finally to exit main loop

This commit is contained in:
Christian Hergert
2024-10-23 11:39:14 -07:00
parent 6d10a4337f
commit 21ebc8f1af

View File

@ -438,22 +438,20 @@ sysprof_cat_fiber (gpointer data)
exit_code = EXIT_SUCCESS;
g_main_loop_quit (main_loop);
return dex_future_new_for_boolean (TRUE);
}
static DexFuture *
sysprof_cat_catch_error_cb (DexFuture *future,
gpointer user_data)
sysprof_cat_finally_cb (DexFuture *future,
gpointer user_data)
{
g_autoptr(GError) error = NULL;
dex_await (dex_ref (future), &error);
g_printerr ("Error: %s\n", error->message);
exit_code = EXIT_FAILURE;
if (!dex_await (dex_ref (future), &error))
{
g_printerr ("Error: %s\n", error->message);
exit_code = EXIT_FAILURE;
}
g_main_loop_quit (main_loop);
@ -490,12 +488,12 @@ main (int argc,
}
dex_future_disown (
dex_future_catch (
dex_future_finally (
dex_scheduler_spawn (NULL, 0,
sysprof_cat_fiber,
g_strdup (argv[1]),
g_free),
sysprof_cat_catch_error_cb,
sysprof_cat_finally_cb,
NULL, NULL));
if (exit_code == -1)