Fixed crash when pressing Y in an empty directory (#102)

This commit is contained in:
Chris Butler 2021-08-04 22:21:08 -04:00 committed by GitHub
parent c36f52cd18
commit 097ac8225c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -118,12 +118,14 @@ namespace GUI {
}
else if (button == SDL_KEY_Y) {
if (item.state == MENU_STATE_FILEBROWSER) {
if ((!item.checked_cwd.empty()) && (item.checked_cwd.compare(cfg.cwd) != 0))
GUI::ResetCheckbox();
if (item.selected < static_cast<int>(item.checked.size())) {
if ((!item.checked_cwd.empty()) && (item.checked_cwd.compare(cfg.cwd) != 0))
GUI::ResetCheckbox();
item.checked_cwd = cfg.cwd;
item.checked.at(item.selected) = !item.checked.at(item.selected);
item.checked_count = std::count(item.checked.begin(), item.checked.end(), true);
item.checked_cwd = cfg.cwd;
item.checked.at(item.selected) = !item.checked.at(item.selected);
item.checked_count = std::count(item.checked.begin(), item.checked.end(), true);
}
}
}
else if (button == SDL_KEY_DLEFT) {