From e19c016c74c9627afe7c4527dfc08d5c77539261 Mon Sep 17 00:00:00 2001 From: qwewer0 <57561110+qwewer0@users.noreply.github.com> Date: Sun, 22 Nov 2020 01:21:43 +0100 Subject: [PATCH] Clear menu history for browse media on insert (#20236) Co-authored-by: Scott Lahteine --- Marlin/src/lcd/marlinui.cpp | 1 + Marlin/src/lcd/menu/menu.cpp | 2 +- Marlin/src/lcd/menu/menu.h | 3 +++ Marlin/src/lcd/menu/menu_media.cpp | 2 -- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 9d0ebe27e4..acf35afb18 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1625,6 +1625,7 @@ void MarlinUI::update() { if (old_status < 2) { TERN_(EXTENSIBLE_UI, ExtUI::onMediaInserted()); // ExtUI response #if ENABLED(BROWSE_MEDIA_ON_INSERT) + clear_menu_history(); quick_feedback(); goto_screen(MEDIA_MENU_GATEWAY); #else diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index 81ac32a60c..1497940ffe 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -206,8 +206,8 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co screen_items = items; if (on_status_screen()) { defer_status_screen(false); + clear_menu_history(); TERN_(AUTO_BED_LEVELING_UBL, ubl.lcd_map_control = false); - screen_history_depth = 0; } clear_lcd(); diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index 66fe73cec1..5782d2070a 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -249,3 +249,6 @@ void _lcd_draw_homing(); #if ENABLED(TOUCH_SCREEN_CALIBRATION) void touch_screen_calibration(); #endif + +extern uint8_t screen_history_depth; +inline void clear_menu_history() { screen_history_depth = 0; } diff --git a/Marlin/src/lcd/menu/menu_media.cpp b/Marlin/src/lcd/menu/menu_media.cpp index 59cb2baa23..7a525d06b5 100644 --- a/Marlin/src/lcd/menu/menu_media.cpp +++ b/Marlin/src/lcd/menu/menu_media.cpp @@ -104,8 +104,6 @@ class MenuItem_sdfolder : public MenuItem_sdbase { } }; -extern uint8_t screen_history_depth; - void menu_media() { ui.encoder_direction_menus();