From 5ca08dbb4df3a030119b81cd56e60eb154f18a18 Mon Sep 17 00:00:00 2001 From: Anthony Pesch Date: Wed, 22 Nov 2017 00:07:56 -0500 Subject: [PATCH] don't attempt to pop the ui history stack if empty --- src/ui.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ui.c b/src/ui.c index 0fa29e27..9e174dd1 100644 --- a/src/ui.c +++ b/src/ui.c @@ -1384,9 +1384,9 @@ void ui_set_page(struct ui *ui, int page_index) { } /* 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); - } else if (next_page == NULL) { + } else if (!next_page) { ui_closed(ui->host); } } @@ -1432,10 +1432,8 @@ int ui_keydown(struct ui *ui, int key, int16_t value) { /* prioritize canceling any open dialog */ if (ui->dlg) { ui_close_dlg(ui, UI_DLG_CANCEL); - } - /* else, pop the history stack */ - else { - ui->history_pos = MAX(ui->history_pos - 1, 1); + } else if (ui->history_pos > 1) { + ui->history_pos = ui->history_pos - 1; } }