Fix browser navigation crashes
This commit is contained in:
@@ -25,8 +25,10 @@ class Screen {
|
||||
Screen() : root_(lv_obj_create(NULL)), group_(lv_group_create()) {}
|
||||
|
||||
virtual ~Screen() {
|
||||
lv_obj_del(root_);
|
||||
// The group *must* be deleted first. Otherwise, focus events will be
|
||||
// generated whilst deleting the object tree, which causes a big mess.
|
||||
lv_group_del(group_);
|
||||
lv_obj_del(root_);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -307,18 +307,13 @@ auto TrackBrowser::GetRecordByIndex(std::size_t index)
|
||||
}
|
||||
ESP_LOGI(kTag, "total tracks %u, getting index %u", total_tracks, index);
|
||||
|
||||
std::size_t current_index = 0;
|
||||
for (const auto& page : current_pages_) {
|
||||
if (index > current_index + page->values().size()) {
|
||||
current_index += page->values().size();
|
||||
continue;
|
||||
for (int i = 0; i < page->values().size(); i++) {
|
||||
if (index == 0) {
|
||||
return page->values().at(i);
|
||||
}
|
||||
index--;
|
||||
}
|
||||
if (index < current_index) {
|
||||
// uhhh
|
||||
break;
|
||||
}
|
||||
std::size_t index_in_page = index - current_index;
|
||||
return page->values().at(index_in_page);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user