From 9f5b97620accf8c3656dc2d9a55c51c2d4d56a79 Mon Sep 17 00:00:00 2001 From: Kostas Missos Date: Sun, 16 Dec 2018 20:21:59 +0200 Subject: [PATCH] Fix return to main when setting an autoboot option This fixes the issue with "More configs". --- bootloader/config/config.c | 12 ++++++------ bootloader/frontend/fe_tools.c | 1 + bootloader/gfx/tui.c | 6 ++++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/bootloader/config/config.c b/bootloader/config/config.c index 7a5313c..4f8cae1 100644 --- a/bootloader/config/config.c +++ b/bootloader/config/config.c @@ -156,7 +156,7 @@ int create_config_entry() return 0; } -void _config_autoboot_list() +static void _config_autoboot_list(void *ent) { gfx_clear_grey(&gfx_ctxt, 0x1B); gfx_con_setpos(&gfx_con, 0, 0); @@ -231,6 +231,9 @@ void _config_autoboot_list() else EPRINTF("\nConfiguration saving failed!"); gfx_puts(&gfx_con, "\nPress any key..."); + + ment_t *tmp = (ment_t *)ent; + tmp->data = NULL; } else goto out2; @@ -251,9 +254,6 @@ out2:; ini_free(&ini_sections); sd_unmount(); - - if (temp_autoboot == NULL) - return; } void config_autoboot() @@ -291,13 +291,13 @@ void config_autoboot() ments[2].caption = " Disable"; ments[2].data = &boot_values[0]; - ments[3].type = MENT_HANDLER; + ments[3].type = MENT_HDLR_RE; if (h_cfg.autoboot_list) ments[3].caption = "*More configs..."; else ments[3].caption = " More configs..."; ments[3].handler = _config_autoboot_list; - ments[3].data = NULL; + ments[3].data = (void *)0xCAFE; ments[4].type = MENT_CHGLINE; diff --git a/bootloader/frontend/fe_tools.c b/bootloader/frontend/fe_tools.c index 9a965c9..079a1f5 100644 --- a/bootloader/frontend/fe_tools.c +++ b/bootloader/frontend/fe_tools.c @@ -322,6 +322,7 @@ void menu_autorcm() ments[4].handler = _disable_autorcm; } ments[4].type = MENT_HDLR_RE; + ments[4].data = NULL; memset(&ments[5], 0, sizeof(ment_t)); menu_t menu = {ments, "This corrupts your BOOT0!", 0, 0}; diff --git a/bootloader/gfx/tui.c b/bootloader/gfx/tui.c index 2ab3ec1..01b9304 100644 --- a/bootloader/gfx/tui.c +++ b/bootloader/gfx/tui.c @@ -206,8 +206,10 @@ void *tui_do_menu(gfx_con_t *con, menu_t *menu) return NULL; break; case MENT_HDLR_RE: - ent->handler(ent->data); - return NULL; + ent->handler(ent); + if (!ent->data) + return NULL; + break; default: break; }