diff --git a/firmware/application/ui_freqman.cpp b/firmware/application/ui_freqman.cpp index daad19b8..7e1b7227 100644 --- a/firmware/application/ui_freqman.cpp +++ b/firmware/application/ui_freqman.cpp @@ -31,24 +31,23 @@ using namespace portapack; namespace ui { -void FrequencySaveView::on_save_name(NavigationView& nav) { - // TODO: Here be a bug. - textentry(nav, desc_buffer, 28); - database.entries.push_back({ value_, "", desc_buffer, (int32_t)options_category.selected_index_value() }); - nav.pop(); +void FrequencySaveView::on_save_name(char * name) { + database.entries.push_back({ value_, "", name, (int32_t)options_category.selected_index_value() }); + nav_.pop(); } -void FrequencySaveView::on_save_timestamp(NavigationView& nav) { +void FrequencySaveView::on_save_timestamp() { database.entries.push_back({ value_, "", str_timestamp, (int32_t)options_category.selected_index_value() }); - nav.pop(); + nav_.pop(); } void FrequencySaveView::focus() { if (error == ERROR_ACCESS) { nav_.display_modal("Error", "File acces error", ABORT, nullptr); + } else if (error == ERROR_DUPLICATE) { + nav_.display_modal("Error", "Frequency already saved", INFO, nullptr); + error = NO_ERROR; } else { - if (error == ERROR_DUPLICATE) - nav_.display_modal("Error", "Frequency already saved", INFO, nullptr); button_save_timestamp.focus(); } } @@ -120,10 +119,12 @@ FrequencySaveView::FrequencySaveView( big_display.set(value); button_save_name.on_select = [this, &nav](Button&) { - on_save_name(nav); + textentry(nav, desc_buffer, 28, [this](char * buffer) { + on_save_name(buffer); + }); }; button_save_timestamp.on_select = [this, &nav](Button&) { - on_save_timestamp(nav); + on_save_timestamp(); }; button_cancel.on_select = [this, &nav](Button&) { @@ -216,6 +217,7 @@ void FreqManView::on_edit_desc(NavigationView& nav) { } void FreqManView::on_delete() { + size_t n; database.entries.erase(database.entries.begin() + menu_view.highlighted()); setup_list(); } @@ -240,7 +242,7 @@ void FreqManView::setup_list() { }); } - menu_view.set_highlighted(menu_view.highlighted()); // Refresh + menu_view.set_highlighted(0); // Refresh } void FreqManView::focus() { diff --git a/firmware/application/ui_freqman.hpp b/firmware/application/ui_freqman.hpp index 9e3b1be6..49d62192 100644 --- a/firmware/application/ui_freqman.hpp +++ b/firmware/application/ui_freqman.hpp @@ -50,8 +50,8 @@ private: std::string str_timestamp { }; //int32_t category_id_ { -1 }; - void on_save_name(NavigationView& nav); - void on_save_timestamp(NavigationView& nav); + void on_save_name(char * name); + void on_save_timestamp(); void on_tick_second(); freqman_db database { }; diff --git a/firmware/application/ui_menu.cpp b/firmware/application/ui_menu.cpp index 2c0e6d8d..5697763a 100644 --- a/firmware/application/ui_menu.cpp +++ b/firmware/application/ui_menu.cpp @@ -111,7 +111,11 @@ MenuView::MenuView( } MenuView::~MenuView() { - clear(); + for (auto child : children_) { + if (!child->id) { + delete child; + } + } rtc_time::signal_tick_second -= signal_token_tick_second; } @@ -129,7 +133,7 @@ void MenuView::on_tick_second() { void MenuView::clear() { for (auto child : children_) { if (!child->id) { - delete child; + remove_child(child); } } } diff --git a/firmware/portapack-h1-havoc.bin b/firmware/portapack-h1-havoc.bin index 1b6a65dd..d888d4a5 100644 Binary files a/firmware/portapack-h1-havoc.bin and b/firmware/portapack-h1-havoc.bin differ