don't attempt to pop the ui history stack if empty

This commit is contained in:
Anthony Pesch 2017-11-22 00:07:56 -05:00
parent 3f2e5ae9f2
commit 5ca08dbb4d
1 changed files with 4 additions and 6 deletions

View File

@ -1384,9 +1384,9 @@ void ui_set_page(struct ui *ui, int page_index) {
} }
/* trigger global callbacks for when the ui is open / closed */ /* trigger global callbacks for when the ui is open / closed */
if (top_page == NULL && next_page != NULL) { if (!top_page && next_page) {
ui_opened(ui->host); ui_opened(ui->host);
} else if (next_page == NULL) { } else if (!next_page) {
ui_closed(ui->host); ui_closed(ui->host);
} }
} }
@ -1432,10 +1432,8 @@ int ui_keydown(struct ui *ui, int key, int16_t value) {
/* prioritize canceling any open dialog */ /* prioritize canceling any open dialog */
if (ui->dlg) { if (ui->dlg) {
ui_close_dlg(ui, UI_DLG_CANCEL); ui_close_dlg(ui, UI_DLG_CANCEL);
} } else if (ui->history_pos > 1) {
/* else, pop the history stack */ ui->history_pos = ui->history_pos - 1;
else {
ui->history_pos = MAX(ui->history_pos - 1, 1);
} }
} }