Bugfix: Fix hardfault when update menu is opened and no hex file is located on disk

This commit is contained in:
Mario Hüttel 2021-11-27 18:47:17 +01:00
parent 96e0931c9f
commit c78477296a

View File

@ -663,21 +663,26 @@ static void gui_update_firmware(struct lcd_menu *menu, enum menu_entry_func_entr
} }
} }
if (entry_type == MENU_ENTRY_FIRST_ENTER || if (list_length) {
previously_selected_file != currently_selected_file) { if (entry_type == MENU_ENTRY_FIRST_ENTER ||
fname = sl_list_nth(file_list, currently_selected_file)->data; previously_selected_file != currently_selected_file) {
menu_lcd_output(menu, 0, "Select File:"); fname = sl_list_nth(file_list, currently_selected_file)->data;
if (fname) menu_lcd_output(menu, 0, "Select File:");
menu_lcd_output(menu, 1, fname); if (fname)
menu_lcd_output(menu, 1, fname);
}
if (button == BUTTON_SHORT_RELEASED) {
fname = sl_list_nth(file_list, currently_selected_file)->data;
menu_display_clear(menu);
updater_update_from_file(fname);
/* This code is here for completeness. It will never be reached! */
sl_list_free_full(file_list, delete_file_list_entry);
}
} else {
menu_lcd_output(menu, 0, "No files!");
} }
if (button == BUTTON_SHORT_RELEASED) {
fname = sl_list_nth(file_list, currently_selected_file)->data; if (button == BUTTON_LONG) {
menu_display_clear(menu);
file_list = NULL;
updater_update_from_file(fname);
/* This code is here for completeness. It will never be reached! */
sl_list_free_full(file_list, delete_file_list_entry);
} else if (button == BUTTON_LONG) {
sl_list_free_full(file_list, delete_file_list_entry); sl_list_free_full(file_list, delete_file_list_entry);
file_list = NULL; file_list = NULL;
menu_entry_dropback(menu, my_parent); menu_entry_dropback(menu, my_parent);